summaryrefslogtreecommitdiffstats
path: root/frontend/pages/_app.js
blob: 27202d53e61f74666972b34e1aaf00a613dadec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import App, { Container } from 'next/app';
import React from 'react';
import { ApolloApp } from 'next-with-apollo';
import withData from '../lib/withData';

// 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 ApolloApp {
  static async getInitialProps({ Component, ctx }) {
    let pageProps = {};

    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps(ctx);
    }

    pageProps.query = ctx.query

    return { pageProps };
  }
}

export default withData(MyApp);