Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
react-draft-wysiwyg set editor state with createWithContent() not showing anything in editor

experiencing problem in setting initial editor state , using createWithContent()

The "richTextDescription" is what stored in database as

 {"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":{}}

setting initial use state hook:

 const [richTextDescription, setRichTextDescription] = useState(
            content.richTextDescription
          );

the state change method:

  const onEditorStateChange = (editorState) => {
        setEditorState(editorState);
        setRichTextDescription(convertToRaw(editorState.getCurrentContent()));
      };

here setting the editor state with createWithContent().

const [editorState, setEditorState] = useState({
    editorState: EditorState.createWithContent(
      convertFromRaw(JSON.parse(richTextDescription))
    ),
  });



<Editor
initialEditorState={editorState}
onEditorStateChange={onEditorStateChange}
}}
/>

the following shows output fine

<div
    dangerouslySetInnerHTML={{
    __html: draftToHtml(JSON.parse(richTextDescription)),
    }}
 ></div>

but the intial editor state which should show the editable text within editor is now showing. it shows blank

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda