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

279
Vistas
React philosophy of "moving state up" causes massive parent component

I'm working on a simple react app that quickly becomes unmanageable due to the "moving state up" philosophy. In the app, there are a number of nested fields in which the user inputs all kinds of data: strings, pixel grids, etc. Each field is a component.

Then, when the user is done, they can export their work in JSON format. Because of this, the parent technically needs access to the state of all the children, so I moved the state from each of the (nested) fields all the way to the parent component. But this becomes massively unwieldy: all the functions for modifying state are concentrated in the parent class, and prop-drilling abounds. This isn't a plain old form--the user is creating an entire document, with nested subsections, so the state and all of the functions that modify it are quite complex.

Here's the thing: the parent component does not need the state of the children until the export button is clicked, and all it needs to do is read it. One could therefore imagine a different solution: store the state in the relevant child component until export, and then, the parent function could collate the states of all its children in a JSON file and export. This seems like a much more elegant solution.

Is there a react-y way of doing this--that is, storing state in children, but sending it up to the parent upon request?

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