I have a property product_des
on my database where all the content of react draft wysiwyg
store. I want to set the default value on my editor from the database.
//State
const [onEditorStateChange, setOnEditorStateChange] = useState<any>()
const [content, setContent] = useState<any>()
<Editor
editorState={onEditorStateChange}
toolbarClassName="toolbarClassName"
wrapperClassName="wrapperClassName"
editorClassName="editorClassName"
onEditorStateChange={newState => {
setOnEditorStateChange(newState)
setContent(draftToHtml(convertToRaw(newState.getCurrentContent())))
}}
/>
Here is my database example:
{
_id: "6231a09c0a292231f0bbd16b",
title: "Controller",
reg_price: "499",
product_des: "<p>PS5</p>
"
}