While trying to set initial value from react hook form it shows that state.get is not a function. I have looked at [this][1] initially but seems like its not working.
const { handleSubmit, formState, control, reset, register } = useForm<any>({
defaultValues: {
title: editData ? editData.title : "",
description: editData ? EditorState.createWithContent(convertFromRaw(JSON.parse(editData.description))) : null
}
});
<div className="wysiwyg-wrapper">
<Controller
control={control}
name={"description"}
render={({ field }) => {
return <Editor
editorState={field.value}
toolbarClassName="toolbarClassName"
wrapperClassName="wrapperClassName"
editorClassName="editorClassName"
onEditorStateChange={(editorState: any) => {
let check = convertToRaw(editorState?.getCurrentContent())
console.log(editorState)
setEditorDescription(JSON.stringify(check))
field.onChange(editorState);
}}
/>
}}
/>
</div>```
[1]: https://stackoverflow.com/questions/39548380/react-draft-js-convertfromraw-not-working/39558101#39558101
[2]: https://i.stack.imgur.com/346zL.png