Search code examples
javascriptreactjsreact-routerreact-router-component

React Router Param


Is it possible to do this with react router?

<Route path="/:reset_password" component={ResetPassword} />
<Route path="/:create_password" component={CreatePassword}/>

I want use different param with different component. I test above code and it doesn't work. the code above work if I change to this:

<Route path="/something1/:reset_password" component={ResetPassword} />
<Route path="/something2/:create_password" component={CreatePassword}/>

thanks for the help


Solution

  • As @chris said, remove the colons and/or assign dedicated routes. React Router can't differentiate between the two routes you've supplied, as they're technically identical (root path + a dynamic parameter.)