Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda