Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

routeParams is not valued for nested routes #4225

Closed
marcellomontemagno opened this issue Nov 28, 2016 · 2 comments
Closed

routeParams is not valued for nested routes #4225

marcellomontemagno opened this issue Nov 28, 2016 · 2 comments

Comments

@marcellomontemagno
Copy link

marcellomontemagno commented Nov 28, 2016

Hi guys, the following routing

<Router>
  <Route path="/" component={App}/>
  <Route path="/aRoute" component={App}>
    <Route path=":myParam" />
  </Route>
</Router>

doesn't value routeParams when navigating to "/aRoute/1"

routeParams is valued if I use optional parameters as follow

<Router>
  <Route path="/" component={App}/>
  <Route path="/aRoute(/:myParam)" component={App}/>
</Router>

looks like a bug to me, is it an intended behaviour?

tested against version 3.0.0

below a runnable version of both scenarios

nested routes: http://codepen.io/anon/pen/QGqWQW?editors=001
optional parameters: http://codepen.io/anon/pen/eBGYyd?editors=001

@pshrmn
Copy link
Contributor

pshrmn commented Nov 28, 2016

From the docs:

routeParams

A subset of this.props.params that were directly specified in this component's route.

If your <Route path=":myParam" /> had a component, that component would have access to props.routeParams.myParam.

@timdorr timdorr closed this as completed Nov 28, 2016
@marcellomontemagno
Copy link
Author

Thanks for the quick response,

I noticed this thing refactoring some route with optional parameters to nested routes.
I did it because of the following issue with the isActive API

3277

I was expecting nothing to break and no need to change the components implementation doing that change.

Maybe a little extra to that line in the doc would not be bad, that route is rendering that component after all :)

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants