javascript - Sub routes not working in react router v4 -
i'm trying nest routes in react router \sports\cricket
sub-routes aren't showing up. following code:
index.js
const root = () => { return ( <router> <div> <route exact path="/" component={home}/> <route path="/sports" component={sports} /> </div> </router> ); };
sports.js
return ( <div> <route path="cricket" component={cricket} /> </div> );
the console logs error 404 whenever try /sports/cricket
:
edit 1: moved nested route inside of sports
component.
nested routes don't work in v4. assign subroutes in component parent route points to. this:
index.js
const root = () => { return ( <router history={browserhistory}> <div> <route exact path="/" component={home}/> <route path="/sports" component={sports}/> </div> </router> ); };
sports.js
return ( <div> <route path="/sports/cricket" component={cricket} /> </div> );
Comments
Post a Comment