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

349
Visualizações
MUIRichTextEditor does not display default value present

I am new to ReactJs. I have treid many ways and solutions to show default value in text editor. But i did not find a suitable answer to it. Below piece of code is what i tried. But i do not get the editor prefilled with database value.

I want MUIRichTextEditor to show the default value in it.

Following is MUIRichTextEditor

<MUIRichTextEditor
      name="text"
      label="Start Tying...."
      toolbarButtonSize="small"
      defaultValue={this.state.text}
      inlineToolbar={true}
      onChange={this.onChange}
/>

Below is how my Editor looks like :

enter image description here

this.onChange

onChange = textData => {
    if (textData.getCurrentContent().getPlainText()) {
        this.setState({
            text: stateToHTML(textData.getCurrentContent()),
        })
    } else {
        this.setState({
            text: "",
        })
    }
};

Have imported the following:

import MUIRichTextEditor from "mui-rte";
import { stateToHTML } from "draft-js-export-html";

How is send my data to edit:

<EditForm 
    onSubmit={this.updateData}
    initialValues={this.state.databaseData}
/>

text gets sent to the edit form, but, the default value is not getting displayed

Data in database is:

{"_id":{"$oid":"61dbc710888107116046198e"},"text":"<p>Text<strong>feild</strong></p>""__v":0}

So, when I edit my text at the front end, I want MUIRichTextEditor to be prefilled with text. Since in database it is saved as html, at the front end as well, in text editor, I want to be displayed in proper format. I do not want to use hooks. Just in ReactJs.

Expected Result when I want to edit (Example):

enter image description here

I don't know how to do it. Help would be greatly appreciated. Thankyou.

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