Programmatically navigate to route with v4 reactive router

So, I am trying to navigate to a route / forecast that I have defined among my routes. When you try to link to a link like:

<Link to="/forecast">Test</Link>

      

Works. But now I am trying to do it programmatically, after clicking a button, and Im not understanding what to do in v4 of a react router. Ive tried this:

history.push('/forecast');

      

Here's what I gathered from the official documentation. But it doesn't work, what should I do when trying to reach the route inside the function?

+3


source to share





All Articles