scalable-react / scalable-react-boilerplate

:star: Scalable feature-first React micro-framework made for Udacity Alumni collaborative projects

Home Page:https://scalable-react-boilerplate.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I define nested routes?

developer239 opened this issue · comments

How do you define nested routes when you don't use jsx?

Hey @developer239! You can see an example in the react router docs. You're looking for the child routes.

From the example

const routes = {
  path: '/',
  component: App,
  indexRoute: { component: Dashboard },
  childRoutes: [
    { path: 'about', component: About },
    {
      path: 'inbox',
      component: Inbox,
      childRoutes: [{
        path: 'messages/:id',
        onEnter: ({ params }, replace) => replace(`/messages/${params.id}`)
      }]
    },
    {
      component: Inbox,
      childRoutes: [{
        path: 'messages/:id', component: Message
      }]
    }
  ]
}

render(<Router routes={routes} />, document.body)

Please let me know if you have any further questions @developer239