adamsoffer / next-apollo

React higher-order component for integrating Apollo Client with Next.js
MIT License
482 stars 64 forks source link

Add layout #108

Open binalfew opened 2 years ago

binalfew commented 2 years ago
If I have the following layout component:
const Layout = ({ children }) => {
  return (
    <div>
      <main>
              {children}
      </main>
    </div>
  );
};

export default Layout;
Use the layout component in my pages (Index.tsx) before passing the page to the withApollo HOC
Index.layout = (page: ReactElement) => (
  <Layout>
    {page}
  </Layout>
)

export default withApollo({ ssr: true })(Index)