-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
  • 7,935
  • 20
  • 55
  • 98

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,142
  • 2
  • 13
  • 19