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

190
Views
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 answers
Answer question

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 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!