123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import App from 'next/app'
- import client from '../lib/apollo'
- import { ApolloProvider } from '@apollo/client'
- import Page from '../components/page'
- /**
- * Next.js uses the `App` component to initialize pages. See:
- * https://github.com/zeit/next.js/#custom-app
- *
- * Using next-with-apollo:
- * https://github.com/lfades/next-with-apollo
- * - Wrapping MyApp in withApollo HOC
- */
- class MyApp extends App {
- static async getInitialProps ({ Component, ctx }) {
- let pageProps = {}
- if (Component.getInitialProps) {
- pageProps = await Component.getInitialProps(ctx)
- }
- // Add the query object to the pageProps
- // https://github.com/wesbos/Advanced-React/blob/master/finished-application/frontend/pages/_app.js
- pageProps.query = ctx.query
- return { pageProps }
- }
- render () {
- const { Component, pageProps } = this.props
- return (
- <ApolloProvider client={client}>
- <Page>
- <Component {...pageProps} />
- </Page>
- </ApolloProvider>
- )
- }
- }
- export default MyApp
|