渲染子组件

如果您删除{props.children},则布局无法呈现我们放置在Layout元素内的内容,如下所示:

  1. export default () => (
  2. <Layout>
  3. <p>This is the about page</p>
  4. </Layout>
  5. )

这只是创建布局组件的一种方式。 以下是创建布局组件的其他一些方法:

  1. import withLayout from '../lib/layout'
  2. const Page = () => (
  3. <p>This is the about page</p>
  4. )
  5. export default withLayout(Page)
  1. const Page = () => (
  2. <p>This is the about page</p>
  3. )
  4. export default () => (<Layout page={Page}/>)
  1. const content = (<p>This is the about page</p>)
  2. export default () => (<Layout content={content}/>)