Accepted answer

Use react-router-dom

You can use react-router-dom (npm package)

In React Class you can use this: this.props.history.push('/login')

And in React Hooks you can use useHistory from react-router-dom:

import { useHistory } from "react-router-dom";

export default function SomeFunction() {

  const history = useHistory();

  const trigerFunction = () => history.push('/login');

  return (
     <div onClick={trigerFunction}></div>


window.location.reload(); it's only refresh the page.

You can save in local storage some that after refresh you know what page to render (but I don't recomend this, and the refresh is unnecessary)


You can change:


this.props.history.push("desired Address");

Related Query

More Query from same tag