Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
useNavigate hook not working in React router

I have two pages, Dashboard and Quiz. Dashboard triggers an event which calls the useNavigate function with the state.

const nav = useNavigate();
const goToTest = (e)=>{

    e.preventDefault()

    nav('/student/Quiz',{state:{id:1}});
  }

In quiz, I then use useLocation to try and get the data but it doesn't seem to work.

function Quiz() {
  const {data} = useLocation();
  console.log(data);

If i don't destructure data in quiz, it shows some json data, but state is always null

hash: ""
key: "(a key was here)"
pathname: "/student/Quiz" (Dashboard and quiz are both in the same directory as student)
search: ""
state: null
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Turns out it was a version issue. This happened on 6.14 but when I updated it to 6.2 it works fine.

The docs had mentioned v6 and above, so I thought I was in the clear.

I'll leave this question up for anyone who gets the same issue.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda