experimentando un problema al configurar el estado inicial del editor, usando createWithContent()
El "richTextDescription" es lo que se almacena en la base de datos como
{"blocks":[{"key":"cipnj","text":"Admore ","type":"header-one","depth":0,"inlineStyleRanges":[{"offset":0,"length":7,"style":"BOLD"}],"entityRanges":[],"data":{}},{"key":"3ncop","text":"jhdf","type":"unstyled","depth":0,"inlineStyleRanges":[{"offset":0,"length":4,"style":"color-rgb(44,130,201)"}],"entityRanges":[],"data":{}},{"key":"2ra8a","text":"no please work !!","type":"header-five","depth":0,"inlineStyleRanges":[{"offset":0,"length":17,"style":"color-rgb(44,130,201)"},{"offset":0,"length":17,"style":"BOLD"}],"entityRanges":[],"data":{}}],"entityMap":{}}configuración del enlace de estado de uso inicial:
const [richTextDescription, setRichTextDescription] = useState( content.richTextDescription );el método de cambio de estado:
const onEditorStateChange = (editorState) => { setEditorState(editorState); setRichTextDescription(convertToRaw(editorState.getCurrentContent())); };aquí configurando el estado del editor con createWithContent().
const [editorState, setEditorState] = useState({ editorState: EditorState.createWithContent( convertFromRaw(JSON.parse(richTextDescription)) ), }); <Editor initialEditorState={editorState} onEditorStateChange={onEditorStateChange} }} />lo siguiente muestra la salida bien
<div dangerouslySetInnerHTML={{ __html: draftToHtml(JSON.parse(richTextDescription)), }} ></div>pero ahora se muestra el estado inicial del editor que debería mostrar el texto editable dentro del editor. se muestra en blanco