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

98
Vistas
How to update multiple dependent setStates in same function using Hooks in functional component

I have a Parent and Child Components. I pass a prop from the Child component into the a Parent Method that acts on multiple dispatches from a useReducer Hook using the following code

in Child

onPress={()=>props.clickTile(props.id)

while receiving the props.id inside the Parent method

in Parent

function clickTile(id)

this is needed to access dynamically created buttons and be able to reach their related state.

in Parent

            if (tileOne !== null) {

               setTileTwo(selectTile); //setState
               //code..

               if (tileTwo !== null) {// doesn't update until another click causing halt
                   //code...
               }

            }

however inside this method I have to call multiple conditionals as well as expressions using the same useReducer state causing issues due to the state not updating until the next click.

for more on passing from Child to Parent see my previous related question

PS. please suggest a better title.

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