How come my route isn't matching with React Router 4? -
i have routes file works expected:
<route path="/app" render={({match}) => ( <switch> <route exact path={`${match.url}/`} component={home} /> <route path={`${match.url}/error`} component={error} /> </switch> </route>
but when try hard code routes, not work. example:
<route path="/app" render={({match}) => ( <switch> <route exact path={`app/`} component={home} /> <route path={`app/error`} component={error} /> </switch> </route>
of course hard coding not want, in case wanted this
<route path="/app"> <switch> <route exact path="app/" component={home} /> <route path="app/error" component={error} /> </switch> </route>
and create app using children
of route
, not render
prop. doing wrong, or how can accomplish this?
react router v4 doesn't use nested routes.
<route path="/app">
match begins /app
, don't think want.
this should enough want:
<switch> <route exact path={`/app/error`} component={error} /> <route path={`/app`} component={home} /> </switch>
Comments
Post a Comment