javascript - components not rendering dynamically with react router v4 -
for reason nested routes in react based application using react-router v4 not working.
the dashboard component rendering 3 child components, namely header , footer & content1 . of these components render default on route /dashboard want content1 component change according url, i.e. content2 component should render on url /dashboard/content2 in place of content1 not happening , hitting url throws 404 error. highly appreciated. following code:
index.js
return ( <router> <div> <route exact path="/" component={login}/> <route path="/dashboard" component={dashboard} /> </div> </router> ); dashboard.js
return ( <div> <header/> <footer/> <switch> <route path="/dashboard/content2" component={content2} /> // hitting route throws 404 error... <route component={content1} /> </switch> </div> );
wiki
Comments
Post a Comment