Say i have 2 components called <Dashboard/>
that is being rendered after a user logged in and <Landing/>
that is being rendered when user is not logged in yet
In reactjs, what should i do if i want to use the same /
route that if the user is not logged in yet it will render <Landing/>
and it will render <Dashboard/>
if the user is logged in?
<Landing/>
is
<Route path="/" component={Landing} onEnter={appOnEnter}>
<IndexRoute component={Home}/>
... Other not-login-required routes ...
</Route>
and Dashboard
is
<Route path="/" component={Dashboard} onEnter={appOnEnter}>
<IndexRoute component={Home} />
... Other login-required routes ...
</Route>
i came accross getComponent/getComponents which i think i can use like
<Route path="/" getComponent={(nextState, cb) => {
// do asynchronous stuff to find the components
cb(null, Course)
}} />
But this doesn't seem to suggest using that method
The reason we don't explicitly support this sort of pattern is because it's fairly atypical to wire things up this way
So what would be the best way to achieve what i want?