ReactTraining / react-history

Manage session history with React
266 stars 23 forks source link

history.push redirects to requested url but does not render related component #31

Open kamleshwebtech opened 3 years ago

kamleshwebtech commented 3 years ago

Hello Sir

I have below routing in app function:

<Route exact path="/" component={ListOfItems}></Route>
<Route path="/list/:searchquery?" component={ListOfItems}></Route>

second Route is working well when i pass any search term but when i try to access first route '/' using history.push('/') calling by function it changes the url in the browser but does not render the component of '/' route.

import { createBrowserHistory } from "history";
const history = createBrowserHistory();

const redirectToHome = () => {
    history.push('/');
  }

could you please suggest me what is the issue? Thanks a lot.