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
Post a Comment