From cd191eddc553ea15ac6e9135cb5e9055e3552e88 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Mon, 14 May 2018 17:03:05 -0500 Subject: Updated next-with-apollo to 2.0 --- frontend/pages/_app.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'frontend/pages/_app.js') diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js index f649067..27202d5 100644 --- a/frontend/pages/_app.js +++ b/frontend/pages/_app.js @@ -1,32 +1,24 @@ import App, { Container } from 'next/app'; import React from 'react'; +import { ApolloApp } from 'next-with-apollo'; import withData from '../lib/withData'; -import { withRouter } from 'next/router'; // Next.js wraps each Page in an 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 { +class MyApp extends ApolloApp { static async getInitialProps({ Component, ctx }) { let pageProps = {}; - const ComposedComponent = withData(Component); - if (ComposedComponent.getInitialProps) { - pageProps = await withData(Component).getInitialProps(ctx); + if (Component.getInitialProps) { + pageProps = await Component.getInitialProps(ctx); } - return { pageProps, query: ctx.query }; - } - render() { - const { Component, pageProps, query } = this.props; - const ComposedComponent = withData(Component); - return ( - - - - ); + pageProps.query = ctx.query + + return { pageProps }; } } -export default MyApp; +export default withData(MyApp); -- cgit v1.3