Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 653 Bytes

create-layout.md

File metadata and controls

35 lines (28 loc) · 653 Bytes

How to create a layout

In order to reuse common elements (e.g. toolbar, sidebar) and render page content (e.g. <p>Test</p>), we can use the props.children property:

Layout.js:

const layout = (props) => (
    <div>
        <div>Toolbar, sidebar, backdrop</div>
        <main>
            {props.children}
        </main>
    </div>
);

export default layout;

App.js:

import Layout from './components/Layout/Layout';

function App() {
  return (
    <Layout>
      <p>Test</p>
    </Layout>
  );
}

export default App;

References: