javascript - react router v4 exact prop trigger 2 component -


<route exact path='/admin/task/create' component={componenta} /> <route exact path='/admin/task/:id' component={componentb} />

i visit http://localhost:3000/task/123 trigger componentb, when hit http://localhost:3000/task/create hit componentb , componenta, why so? thought exact prop alrdy solve that?

i think routers independent of each other, second router receives "create" :id.

you have wrap routers switch

<switch>     <route exact path='/admin/task/create' component={componenta} />     <route exact path='/admin/task/:id' component={componentb} /> </switch> 

https://github.com/reacttraining/react-router/blob/master/packages/react-router/docs/api/switch.md


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -