This is the sample code:
<Route exact path='/user'>
<UsersList />
</Route>
<Route path='/user/:name'>
<Sidebar />
<User />
</Route>
UsersListcomponent is like a home/landing page.UsersListandSidebarboth the components contains list of links. When we click any of the link, we will be redirected to that users page.Usercomponent will render the information of that specific user.
Let say we are on /user/john and want go on /user/jack. But when I am doing this i.e. when I am clicking on the link to go from /user/john to /user/jack, React is re-rendering the Sidebar component.
But I want that Sidebar component should render only once and only when path='/user/:name'. So, how to do it?