Reputation: 23
I'm not able to send data when user right clicks on the link and selects Open link in new tab but works perfectly fine when user does a left click on link.
<Link to={{pathname: '/student/edit',state:{userId:rowData.id}}}>
Edit
</Link>
/student/edit is a path defined in my Routes
<Route exact path="/student/edit" component={StudentCandidate}/>
Upvotes: 0
Views: 51
Reputation: 13115
You cannot pass state to a new window/tab. Instead, you would need to pass the data as parameters:
<Link to={{pathname: '/student/edit', userId: rowData.id}}>
Edit
</Link>
Then in your Route, expect them in the path
<Route exact path="/student/edit/:userId" component={StudentCandidate}/>
Consider this similar SO question/answer: React Router passing params. How to?
Upvotes: 2