Render multiple components in React Router Render multiple components in React Router reactjs reactjs

Render multiple components in React Router


To passe multiple component you can do like this :

<Route path="groups" components={{main: Groups, sidebar: GroupsSidebar}} /><Route path="users" components={{main: Users, sidebar: UsersSidebar}}>

See the doc here : https://github.com/ReactTraining/react-router/blob/v3/docs/API.md#named-components


In v4, according to the docs, you can render multiple components like this:

<Route path='/some-path' render={() =>  <Fragment>    <FirstChild />    <SecondChild />  </Fragment>} />


Instead of using div's you can use Fragments.`

<Route path='/some-path' render={props =>  <Fragment>    <Child 1/>    <Child 2/>  </Fragment>} />

`