Rocon Website

Nested Routes

Sometimes, a nested useRoutes call is useful. If a component rendered under useRoutes makes another call of useRoutes, routes rendered by the secondary call are automatically treated as children of the parent route. Child route builders should be hidden inside a component so that the child routes are only accessible during the component is rendered.

This is done by a nested route whose only concern is the ?tab=tab2 part. Other parts of URL is inherited by the parent route.

The benefit of storing the tab information in the search query is that the information becomes recoverable from the URL. Also, with Rocon everything regarding the tab query parameter is enclosed in the page's component, as shown in the next tab.