Skip to content

Commit

Permalink
Fix assignment of props in WithApollo.getInitialProps (#11236)
Browse files Browse the repository at this point in the history
The props are being assigned incorrectly based on the `inAppContext`, they should be wrapped in `pageProps` when `inAppContext` is true, not the other way around. This will cause a new apollo client to be created during `getDataFromTree` instead of using the one that has already been created on the server.
  • Loading branch information
bgoerdt authored Mar 24, 2020
1 parent 16a97c8 commit db57ad3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/with-apollo/lib/apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ export const withApollo = ({ ssr = false } = {}) => PageComponent => {
// we need to modify their props a little.
let props
if (inAppContext) {
props = { ...pageProps, apolloClient }
} else {
props = { pageProps: { ...pageProps, apolloClient } }
} else {
props = { ...pageProps, apolloClient }
}

// Take the Next.js AppTree, determine which queries are needed to render,
Expand Down

0 comments on commit db57ad3

Please sign in to comment.