diff options
| author | Luis Alvarez <luisito453@gmail.com> | 2018-05-14 17:03:05 -0500 |
|---|---|---|
| committer | Luis Alvarez <luisito453@gmail.com> | 2018-05-14 17:03:05 -0500 |
| commit | cd191eddc553ea15ac6e9135cb5e9055e3552e88 (patch) | |
| tree | d52d61addc2d63fa849f794df82778cd4bcbc445 /frontend | |
| parent | 6e85baf21f312f692bb31c082ae582696c394222 (diff) | |
Updated next-with-apollo to 2.0
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/lib/withData.js | 2 | ||||
| -rw-r--r-- | frontend/package.json | 2 | ||||
| -rw-r--r-- | frontend/pages/_app.js | 24 |
3 files changed, 10 insertions, 18 deletions
diff --git a/frontend/lib/withData.js b/frontend/lib/withData.js index e1795c1..3210cf6 100644 --- a/frontend/lib/withData.js +++ b/frontend/lib/withData.js @@ -36,4 +36,4 @@ const client = new ApolloClient({ // TODO don't export client for page.js export { client }; -export default withApollo({ client, getInitialProps: true }); +export default withApollo({ client }); diff --git a/frontend/package.json b/frontend/package.json index 8382b0f..9979370 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -23,7 +23,7 @@ "graphql-tag": "^2.9.2", "lodash.debounce": "^4.0.8", "next": "^6.0.2", - "next-with-apollo": "^1.0.6", + "next-with-apollo": "^2.0.2", "nprogress": "^0.2.0", "prop-types": "^15.6.1", "react": "^16.3.2", 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 <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 { +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 ( - <Container> - <ComposedComponent {...pageProps} query={query} /> - </Container> - ); + pageProps.query = ctx.query + + return { pageProps }; } } -export default MyApp; +export default withData(MyApp); |
