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

73
Views
Estado que no se actualiza en promesas

Tengo los siguientes estados:

 const[value1,setValue1]=useState(); const[value2,setValue2]=useState(); function promiseExecutionMethod() { let Value1Promise=Collection.fetValue() .then((res)=> { setValue1(res); }); let Value2Promise=Collection.fetValue() .then((res)=> { setValue2(res); }); Promise.all([Value1Promise,Value2Promise]).then(([result1,result2])=>{ console.log(value1); //cannot see updated states here console.log(value2); //cannot see updated states here } } useEffect(()=>{ console.log(value1); //can see updated state },[value1]); useEffect(()=>{ console.log(value2); //can see updated state },[value2]);

Aquí estoy cambiando de estado en promesa. UseEffect también muestra estados modificados.

Pero no puedo ver los estados cambiados en el método Promise.All(..).Then.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hice uso de otro estado -

 const[render,setRender]=useState(0);

y en Promise.all([..]).then(([..])

 Promise.All([Value1Promise,Value2Promise]).then(([result1,result2])=>{ setRender(render+1); }

A través de esto, puedo acceder a estados actualizados.

about 4 years ago · Juan Pablo Isaza Report
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!