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

143
Visualizações
Expect assignment or function call instead saw expression contentEditable div

I am using a library called react-contentEditable. The div has an html prop and a value. I am mixing the text with labels. When I add the label into the div it registers an onChange that is setting the { html: target.value }. The html is fine, but I need the value prop to store only the text within the label, not the added html to create the label.

Example, When the value is saved with onChange it looks like this

Hi, firstName How are you doing today?

I need value to look like Hi, firstname How are you doing today?

My approach is to do state.value.replace(/<label class-"p-1" >, " ")

However I am getting the error:Expected an assignment or function call and instead saw an expression

import React, { createRef, useRef, Fragment, useState, useEffect} from 'react';
const contentEditable = createRef()

const [textValue, setTextValue] = useState({value: "", html: ""});

 const component = () => {
<div>
 <ContentEditable
                          name="body"
                          innerRef={contentEditable}
                          html={textValue.html}
                          value={textValue}
                          
                          onChange={({target}) => {  
                            const newValue = textValue.html.replace(/<label contentEditable=false class=p-1 bg-primary text-white rounded-capsule shadow-none fs--3>/, " ") 
                            setTextValue({ ...textValue, value: newValue, html: target.value}), setTemplate({...template, [target.name]: target.value})}}
                          style={{minHeight: "10em"}}
                          className="border border-2x border-300 bg-light rounded-soft fs-1"
                      />
</div>

}

export default Component
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