niuware/mui-rte

Integration with React hook form

dashty94 opened this issue · 1 comments

Checklist

Description

How do you integrate it with React hook Form? I can't get the value of the editor and pass it to the form

Wrap it on Controller, Only way to get data is onSave so you need to save it by refs and use onChange of controller under save event:

<Controller
  control={control}
  name="editor"
  render={(
    { onChange }
  ) => (
          <MUIRichTextEditor
                ref={ref}
                onChange={()=>ref.current.save()}
                onSave={data=>onChange(data)}
              />
  )}
/>