Skip to content

Commit

Permalink
Add Automatic Static Optimization warning
Browse files Browse the repository at this point in the history
  • Loading branch information
HaNdTriX committed Feb 6, 2020
1 parent 82a5468 commit 205014f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/with-apollo/lib/apollo.js
Expand Up @@ -37,6 +37,15 @@ export const withApollo = ({ ssr = true } = {}) => PageComponent => {
const { AppTree } = ctx
const inAppContext = Boolean(ctx.ctx)

if (process.env.NODE_ENV === 'development') {
if (inAppContext) {
console.warn(
'Warning: You have opted-out of Automatic Static Optimization due to `withApollo` in `pages/_app`.\n' +
'Read more: https://err.sh/next.js/opt-out-auto-static-optimization\n'
)
}
}

if (ctx.apolloClient) {
throw new Error('Multiple instances of withApollo found.')
}
Expand Down

0 comments on commit 205014f

Please sign in to comment.