I have read the onEnter not called in React-Router but I do not know how to fix my problem. I just want to check the login status and redirect
index.js
import indexRoutes from "routes/index.jsx";
ReactDOM.render(
<Router history={hist}>
<Switch>
{indexRoutes.map((prop, key) => {
return <Route path={prop.path} component={prop.component} key={key} />;
})}
</Switch>
</Router>,
document.getElementById("root")
);
How to change my code to this?
<Route exact path="/home" render={() => (
isLoggedIn() ? (
<Redirect to="/front"/>
) : (
<Home />
)
)}/>