React-apollo: getDerivedStateFromProps: Cannot read property `currentResult` of undefined. React 16

Created on 2 Mar 2018  路  5Comments  路  Source: apollographql/react-apollo

Intended outcome:
Just updated my project to [email protected] and got many warnings about deprecation.
So i started on fixing it and one of the features of new React that componentWillReceiveProps gets removed. So this method was replaced by static one - getDerivedStateFromProps which is called both on initial mounting and on re-rendering of the component.

Actual outcome:
After componentWillReceiveProps replace with getDerivedStateFromProps i got error. (Attached)
image uploaded from ios 2

How to reproduce the issue:
Simply upgrade to [email protected] and replace componentWillReceiveProps with getDerivedStateFromProps.
You will get an error

Version

react-native@<0.54.0-rc.4>
react@<16.3.0-alpha.1>
apollo-client@<2.2.2>

https://github.com/apollographql/apollo-client/issues/3101

Most helpful comment

I'm on [email protected] with [email protected], didn't touch any component life cycle methods just added a graphql query to a component which doesn't use any component life cycle methods and getting this error also.

Also for more info here is the error I get, which causes the app to crash:

Uncaught TypeError: Cannot read property 'currentResult' of undefined
    at GraphQL.dataForChild (react-apollo.browser.umd.js:540)
    at GraphQL.render (react-apollo.browser.umd.js:590)
    at finishClassComponent (react-dom.development.js:7873)
    at updateClassComponent (react-dom.development.js:7850)
    at beginWork (react-dom.development.js:8225)
    at performUnitOfWork (react-dom.development.js:10224)
    at workLoop (react-dom.development.js:10288)
    at HTMLUnknownElement.callCallback (react-dom.development.js:542)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:581)
    at invokeGuardedCallback (react-dom.development.js:438)

All 5 comments

I got the same issue as well! Just upgraded to the React 16.3 alpha.

Same.

I'm on [email protected] with [email protected], didn't touch any component life cycle methods just added a graphql query to a component which doesn't use any component life cycle methods and getting this error also.

Also for more info here is the error I get, which causes the app to crash:

Uncaught TypeError: Cannot read property 'currentResult' of undefined
    at GraphQL.dataForChild (react-apollo.browser.umd.js:540)
    at GraphQL.render (react-apollo.browser.umd.js:590)
    at finishClassComponent (react-dom.development.js:7873)
    at updateClassComponent (react-dom.development.js:7850)
    at beginWork (react-dom.development.js:8225)
    at performUnitOfWork (react-dom.development.js:10224)
    at workLoop (react-dom.development.js:10288)
    at HTMLUnknownElement.callCallback (react-dom.development.js:542)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:581)
    at invokeGuardedCallback (react-dom.development.js:438)

Update to react-apollo@next it fixes an issue with getDerivedStateFromProps

Closing - housekeeping

Was this page helpful?
0 / 5 - 0 ratings

Related issues

voodooattack picture voodooattack  路  3Comments

reggi picture reggi  路  3Comments

mpgon picture mpgon  路  3Comments

tomitrescak picture tomitrescak  路  3Comments

baldurh picture baldurh  路  3Comments