Sometimes, we want to pass props in Link with React Router.
In this article, we’ll look at how to pass props in Link with React Router.
How to pass props in Link with React Router?
To pass props in Link with React Router, we can pass them directly tro the Route
component the Link
component is linking to.
For instance, we write
<Route name="ideas" path="/:id" handler={createIdeaView} />;
to set the name
prop of the Route
to 'ideas'
to pass the name
prop to the component being rendered by the Route
.
Conclusion
To pass props in Link with React Router, we can pass them directly tro the Route
component the Link
component is linking to.