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

115
Views
history.push not working open in new tab in react

I am new to react js and I am a self-learner. I need to pass some data with my react route and access this data on another side...So I used useHistory() hook to accomplish my task. But now I have some errors. I can only route with mouse click event only. I can't route using open in new tab or my mouse wheel. I have no idea what's going on with my code. So Anyone can help me with that...Thank you.

  const sendPixelData = () => {
    history.push({
      pathname: `product/${product._id}`,
      state: { detail: product },
    });
  };


 <Link onClick={sendPixelData}> Do some logic and other thing  </Link>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A Link component from react-router should not have an onClick parameter but follow the props needed according to the documentation:

https://v5.reactrouter.com/web/api/Link

If you want to pass data you can use the following syntax:

<Link
  to={{
  pathname: `product/${product._id}`,
  state: { detail: product },
  }}
/>
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!