search

Home  >  Q&A  >  body text

Default values ​​in Sun editor in React

I want to set default values ​​for Sun editor.

The default value I got from the database

I set the default value like this but it doesn't work.

<SunEditor
     autoFocus={true}
     onChange={handleEditorChange}
     setOptions={toolbarOptions}
     defaultValue={guide.description}
/>

Data in the database Enter image description here

Only this works

<SunEditor
     autoFocus={true}
     onChange={handleEditorChange}
     setOptions={toolbarOptions}
     defaultValue={"<p>The editor's default value</p>"}
/>

P粉438918323P粉438918323473 days ago664

reply all(1)I'll reply

  • P粉885035114

    P粉8850351142023-09-09 09:53:46

    Try the api function of react-sun-editor

    <SunEditor
         autoFocus={true}
         onChange={handleEditorChange}
         setOptions={toolbarOptions}
         setContents={guide.description}
    />

    Suneditor-react readme file link

    reply
    0
  • Cancelreply