Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda