Source:  Twitter logo

I have a route config like this.

<Route path="group/:groupId" component={NonPropertyView}>
<Route path="group/:groupId/line/:lineId" component={NonPropertyView} />
<Route path="group/:groupId/line/:lineId/property/:propertyId" component={PropertyView} />

But can I do this ?

<Route path="group/:groupId" component={NonPropertyView}>
  <Route path="line/:lineId" component={NonPropertyView}>
    <Route path="property/:propertyId" component={PropertyView} />
  </Route>
</Route>

What I am looking for is an option to just render Component for leaf Route without rendering a parent route Component. Is this possible?

Yes - use <IndexRoute>s. For example, write the above as:

<Route path="group/:groupId">
  <IndexRoute component={NonPropertyView} />
  <Route path="line/:lineId">
    <IndexRoute component={NonPropertyView} />
    <Route path="property/:propertyId" component={PropertyView} />
  </Route>
</Route>
15 users liked answer #0dislike answer #015
taion profile pic
taion

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).