xyz-data / pluralsight-redux-starter

Starter kit for React and Redux in ES6 on Pluralsight
0 stars 0 forks source link

react-router v4 & no `IndexRoute` any more #2

Open xgqfrms-GitHub opened 7 years ago

xgqfrms-GitHub commented 7 years ago

Switch


<Route path="/about" component={About}/>
<Route path="/:user" component={User}/>
<Route component={NoMatch}/>

import { Switch, Route } from 'react-router'

<Switch>
    <Route exact path="/" component={Home}/>
    <Route path="/about" component={About}/>
    <Route path="/:user" component={User}/>
    <Route component={NoMatch}/>
</Switch>

/* there will only ever be one child here */

<Fade>
    <Switch>
        <Route/>
        <Route/>
    </Switch>
</Fade>

<Fade>
    <Route/>
    <Route/>
</Fade>

/* there will always be two children here, one might render null though, making transitions a bit more cumbersome to work out */

https://reacttraining.com/react-router/web/api/Switch

xgqfrms-GitHub commented 7 years ago