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

154
Views
La variable en useState no se actualiza en la devolución de llamada useEffect
const Tweet = ({ tweet, checkedList, setCheckedList }) => { const [isChecked, setChecked] = useState(false); useEffect(() => { checkedList === [] && setChecked(false); }, [checkedList, isChecked]); return ( <div className="tweet"> <h3>Name : {tweet.name} </h3> <p>{tweet.tweet}</p> <input type="checkbox" checked={isChecked} onChange={() => { setChecked(!isChecked); checkedList.find((e) => e === tweet.id) === undefined ? setCheckedList([...checkedList, tweet.id]) : setCheckedList(checkedList.filter((e) => e !== tweet.id)); }} /> </div> ); };

Tengo un componente de tweet que tiene su propio estado. Hay una lista externa marcada que es básicamente una matriz de ID de tweets verificados. Pero una vez que restablecí la checkedList = [] , estoy tratando de restablecer los tweets verificados por useEffect. Pero no puedo hacerlo. Quiero que todos los estados de los tweets estén desmarcados. Qué estoy haciendo mal ?

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

0

checkedList === [] nunca será verdadera.

intente verificar la longitud de la matrizcheckList.

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!