I'm using React Router 4.2.0. In my scenario I have to load different components in same url.
I have two components Login
and Dashboard
when I run localhost:3000
component should load based on the localstorage
flag.
I tried with following code It shows 404 page
<Route path='*' component={NotFound} />
<Route path="/" render={(props) => {
if (localStorage.getItem('user')) {
return <Dashboard />
}
else {
return <Login />
}
}} />