Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!