Categories
React Answers

How to pass props in Link with React Router?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *