diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-05-09 11:25:33 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-05-09 11:25:33 -0400 |
| commit | 8ed7d5b734ba588fe0570e0e22f21a0fcda13422 (patch) | |
| tree | 54bf1cf6370eeae7e3217f26a49e6b021ae7d8a7 /frontend/pages/_app.js | |
| parent | ad3671675719eb11a81245bffbe0fb18880b479b (diff) | |
Moving styles to folder
Diffstat (limited to 'frontend/pages/_app.js')
| -rw-r--r-- | frontend/pages/_app.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js new file mode 100644 index 0000000..5cedb5a --- /dev/null +++ b/frontend/pages/_app.js @@ -0,0 +1,33 @@ +import App, { Container } from 'next/app'; +import React from 'react'; +import { withRouter } from 'next/router'; + +// Next.js wraps each Page in an <App></App> component. This is handy for when you want to persist anything from page to page, or just access a component that is 1 level higher than each page. + +// This code is taken right from the Next.js docs, and then we add the Router to the page props, which is why we need a custom _app.js + +class MyApp extends App { + static async getInitialProps({ Component, router, ctx }) { + let pageProps = {}; + + if (Component.getInitialProps) { + pageProps = await Component.getInitialProps(ctx); + } + + // surface the router on each page + pageProps.router = router; + + return { pageProps }; + } + + render() { + const { Component, pageProps } = this.props; + return ( + <Container> + <Component {...pageProps} /> + </Container> + ); + } +} + +export default withRouter(MyApp); |
