scalable-react / scalable-react-boilerplate

:star: Scalable feature-first React micro-framework made for Udacity Alumni collaborative projects
https://scalable-react-boilerplate.herokuapp.com/
MIT License
259 stars 56 forks source link

How do I define nested routes? #61

Closed developer239 closed 7 years ago

developer239 commented 7 years ago

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

RyanCCollins commented 7 years ago

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)
RyanCCollins commented 7 years ago

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