Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!