You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it seems that nesting 2 MapComponent like this is allowed by the router and does not lead to the MapComponent rendered twice.
Now, the problem is I want to have some additional routes being rendered on top of MapComponent, whether or not an :id was specified.
So paths like: /cities /cities/1 /about
should all be possible and the MapComponent should be rendered beneath the About component.
Question is: How would the routes have to be nested and are there some kind of default values so that /about would fill up the missing route params of MapComponent with some defaults like :scope="cities" && :id=""
The text was updated successfully, but these errors were encountered:
You've got a subtle misunderstanding of how routes nest. For the /cities/1 url, what essentially gets rendered is:
<MapComponent><MapComponent/></MapComponent>
or in other words:
<MapComponentchildren={<MapComponent>}>
So, you've got an odd route combination. The MapComponent isn't rendered twice because it's not rendering this.props.children. This would be a better config:
You only get the id param because we pass the fully parse params to every route component. So, it's a happy accident all of this works. But it would be better with a proper <IndexRoute>.
Thanks Tim, I always suspected something looks fishy with the routes. Copied that schema somewhere from the web.
Sad to see absolute routes to go away. I found them quite easy to spot in the config
lockbot
locked as resolved and limited conversation to collaborators
Jan 21, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have component that renders a map with a list of markers depending on
:scope
and potentially a detail defined by:id
.it seems that nesting 2
MapComponent
like this is allowed by the router and does not lead to theMapComponent
rendered twice.Now, the problem is I want to have some additional routes being rendered on top of
MapComponent
, whether or not an:id
was specified.So paths like:
/cities
/cities/1
/about
should all be possible and the
MapComponent
should be rendered beneath theAbout
component.Question is: How would the routes have to be nested and are there some kind of default values so that
/about
would fill up the missing route params ofMapComponent
with some defaults like:scope="cities" && :id=""
The text was updated successfully, but these errors were encountered: