Commit a450502a authored by Jerome Fitzgerald's avatar Jerome Fitzgerald Committed by Tim Neutkens

[fix] with-apollo: Cannot read property 'data' (#3226)

* [fix] with-apollo: Cannot read property 'data'

When we create the initial serverState, we need to create the
 eventual construct of the Apollo Data to reside within

Later in the constructor this allows for the initApollo to either
 be generated from SSR, or to init from scratch.

Fixes
> Cannot read property 'data' of undefined
> TypeError: Cannot read property 'data' of undefined

* [refactor] with-apollo: reduce init `serverState`

No need to explicitly set `data` as empty.
This trims up 4 lines. 😀️
parent 6089377c
...@@ -17,7 +17,8 @@ export default ComposedComponent => { ...@@ -17,7 +17,8 @@ export default ComposedComponent => {
} }
static async getInitialProps (ctx) { static async getInitialProps (ctx) {
let serverState = {} // Initial serverState with apollo (empty)
let serverState = { apollo: { } }
// Evaluate the composed component's getInitialProps() // Evaluate the composed component's getInitialProps()
let composedInitialProps = {} let composedInitialProps = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment