How to create a dynamic route in React router?


I have a route /books which lists all the books, but whenever the user clicks on a particular book I want the page to be redirected to book/_id_

How can I do this?

I'm using react-router

1 Answer

4 years ago by

In App.js

<Route path="/books/:id" component={Detailed} />

In the Link

<Link to={`/books/${book.id}`}>
   <p>{book.name}</p>
</Link>
4 years ago by Divya