1

I understand in react to route to another view, we can use something like below

<li><Link to={'/'} className="nav-link"> Home </Link></li>

But i would like to route to another route in a js method.

Please let me know if its possible.

Frontend developer
  • 469
  • 1
  • 6
  • 18
  • Please checkout the [docs](https://reactrouter.com/web/api/Hooks/usehistory) for `react-router`'s `useHistory`. If in a class component, [`withRouter`](https://reactrouter.com/web/api/withRouter) can help you accomplish the same. – Brian Thompson Aug 20 '20 at 18:17

1 Answers1

1

You can use history props if you want to go to Home page this.props.history.push("/") U need to call this inside class component for function props.history.push("/")

ikmo
  • 195
  • 1
  • 10