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

263
Views
¿Cómo corregir la advertencia de dependencia faltante al usar useEffect React Hook? estoy usando la aplicación nextjs

La advertencia que estoy recibiendo:

 Warning: React Hook useEffect has a missing dependency: 'router'. Either include it or remove the dependency array

Y el código que escribo en _app.js:

 const router = useRouter(); useEffect(() => { router.events.on('routeChangeStart', ()=>{ setProgress(40) }) router.events.on('routeChangeComplete', ()=>{ setProgress(100) }) // console.log("I am refreshed!") try { if(localStorage.getItem("cart")){ setcart(JSON.parse(localStorage.getItem("cart"))) saveCart(JSON.parse(localStorage.getItem("cart"))) } } catch (error) { console.error(error) localStorage.clear() } let token = localStorage.getItem("token"); if(token){ setuser({value: token}) setkeyMaker(Math.random()) } }, [router.query])

¡y también he importado {useEffect} y {useRouter} de reaccionar! ¡Por favor, ayúdame a solucionar este problema!

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

0

use la instancia del enrutador en su lugar,

 import Router from 'next/router';

Puede resolver el problema fácilmente.

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!