reactjs redirect react docs code example
Example 1: react router dom
npm install react-router-dom
Example 2: redirect to in react js
<Route exact path="/">
{loggedIn ? <Redirect to="/dashboard" /> : <PublicHomePage />}
</Route>
npm install react-router-dom
<Route exact path="/">
{loggedIn ? <Redirect to="/dashboard" /> : <PublicHomePage />}
</Route>