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

414
Views
How to pass data between two pages in React js with react router dom -v6 in through class components

I search through articles and went through many stack overflow questions but I am still resolving the issue.


In react router dom v5, it is easier to pass data through state object as shown in the link answers: React-router - How to pass data between pages in React?

In react-router-dom v5:

<Link to={{

pathname: '/show',
 state: {id: 1, name: 'sabaoon', shirt: 'green'}
         }} >
         View Details</Link>   

the state should be received in another page via this.props.location.state.id etc.


but now in v6 the same method is not passing state object to the location of another page.

When I tried to console log the this.props.location on another page to which I am passing data it is giving me 'undefined' on console.

How we can do the same thing with v6.

Note: I want to do it in class component of react not in function component and I don't want to share it through params as well.

about 4 years ago · Juan Pablo Isaza
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!