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

340
Views
How to pass parameters with React-router-dom version 6 useNavigate and typescript

I am trying to send the variable id to another page using useNavigate in react-router-dom version 6. Here is what I am trying:

const handleSelect = (id: number) => {
    navigate('/Players', {
      userId: id,
    });
  };

However I I am getting the error: Argument of type '{ userId: number; }' is not assignable to parameter of type 'NavigateOptions'. Object literal may only specify known properties, and 'userId' does not exist in type 'NavigateOptions'.ts(2345)

I can't find any useful information on NavigateOptions or what type it is looking for. If I remove the parameter userId then I can navigate to the Player page just fine. It is just the parameter that is causing the problem. What can I do about this issue? Could someone provide some documentation on this?

What would be an example of a parameter that is of type NavigateOptions?

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

0

Did you mean to add state to the navigation? Original:

const handleSelect = (id: number) => {
    navigate('/Players', {
      userId: id,
    });
  };

Changed to (with state):

const handleSelect = (id: number) => {
    navigate('/Players', {
      state: {
        userId: id,
      }
    });
  };

Then you can reference props.location.state.userId in the Players page.

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!