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

216
Visualizações
How to merge react props with external JSON

Code Sandbox: https://codesandbox.io/s/frosty-yalow-19k5u7?file=/src/Item.tsx

Problem

I have a tiptap editor (ProseMirror under the hood) component that accepts a content value as props.

This value is first merged with a default JSON object (which is a valid ProseMirror state), then I put this merged object in a Ref object.

Finally the ref object is the initialization state of the editor.

However, When I loop through the data and create multiple editors, they all have the same value (the last one in the data object).

First try:

DEFAULT.content[0].content[0].text = content;

I also tried

const defaultContent = { ...DEFAULT };
defaultContent.content[0].content[0].text = content;

However, if I pass props.content to useRef directly, it works. What am I doing wrong here?

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