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

141
Views
REACCIONAR: Regreso anticipado, generó menos ganchos de los esperados

Estoy trabajando en un proyecto que crea una extensión de Chrome. Estoy tratando de devolver un objeto y quiero actualizarlo cuando cambió curTab. Sin embargo, recibo un error: se generaron menos ganchos de los esperados. ¿Cómo puedo arreglar eso?

 export const CategoryHandling = () => { const tabHosts = useSelector((state: RootState) => state.tabHosts) const curTab = useSelector((state: RootState) => state.currentTab) const ns3Cache = useSelector((state: RootState) => state.ns3Cache) const [ctgObject, setCategoryObject] = useState({ ads: [], malware: [], tracking: [], family: [], adult: [], }) useEffect(() => { setCategoryObject({ ads: [], malware: [], tracking: [], family: [], adult: [], }) }, [curTab]) const hosts = curTab?.id ? tabHosts[curTab.id] : [] hosts && hosts.length !== 0 && hosts.map((host) => { if ( ns3Cache?.[host] && ns3Cache?.[host].length !== 0 && !ns3Cache[host].hasOwnProperty('isLoading') ) { ns3Cache[host].map((matchesItem) => { if ( !ctgObject[matchesItem['list_category']].includes( matchesItem['hostname'] ) ) { ctgObject[matchesItem['list_category']].push( matchesItem['hostname'] ) } }) } }) return ctgObject }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto se debe a que se llaman ganchos dentro de iteraciones o bloques condicionales, los escenarios más comunes en los que encontré este tipo de error fueron como:

 // Using useSelector inside a map function const myList = someIds.map((id) => useSelector((state) => state.someSlice[id])); // Calling useEffect inside if block if(someCondition) { useEffect(() => { // doing some stuff }, []); }

Busque este tipo de errores en sus componentes.

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!