U
U
Username2018-04-09 19:06:22
React
Username, 2018-04-09 19:06:22

How to render a common template for pages in React Router?

Good afternoon, There is a site frame in the MainLayout component that accepts {this.props.children} It was possible to nest in the react-router
libraries , as you can see, I create a Route and specify the MainLayout template for it and all the descendants that will be specified in it will be transferred like {this.props.children} . How to do the same in the react-router-dom library ?

ReactDOM.render((
  <Router>
    <Route component={MainLayout}>
      <Route path="/" component={Home} />
      <Route component={SearchLayout}>
        <Route path="users" component={UserList} />
        <Route path="widgets" component={WidgetList} />
      </Route> 
    </Route>
  </Router>
), document.getElementById('root'));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kn1ght_t, 2018-04-09
@kn1ght_t

it’s not very clear why you need routes without paths
, maybe mainlayout and searchlayout should take the necessary components into themselves through props?
or just make divs with the necessary styles and put routes in them)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question