How to redirect to a page and re-render that page at the same time

276 views Asked by At

So I have buttons with functions in them in my React JS app and if the user hits the button(for example: Save) I have them redirect to the home page using history.push("/home");. This works good however it doesn't re-render my home page so none of the data that was updated is shown. I'm wondering how I can redirect to and re-render that home page when a user clicks on Save.

1

There are 1 answers

1
waz On

Try using React Router LINK

import {
   BrowserRouter as Router,
   Switch,
   Route,
   Link
} from "react-router-dom";

Then use it like this:

<Link to="/">Home</Link>

This will change the history.

You can also add onClick functions to it as well.