-1

The <Redirect> tag can be used, to redirect to another route from within React render method. How can I do the same within a React component method like ? componentDidMount ?

Oblomov
  • 8,953
  • 22
  • 60
  • 106

1 Answers1

-1

You can import history and use history.push to programatically navigate your React Router project in lifecycle methods or methods.

React-Router Docs - History

Win
  • 5,498
  • 2
  • 15
  • 20