You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
When skip transitions from true to false due to a prop change, the options method is called several times. The times it is called to retrieve for example the variables for the query it is called with the components nextProps. But the internal getClient method calls it with this.props. As this hasn't been brought up as of yet, I recon nobody has used skip in the way I did.
So as long as there's no person property available I don't want to execute the query.
But the moment the person property is set, options is called several times. Not sure of the order, but at least for skip, variables and client. When it is called for skip or variables, the nextProps are passed, and ownProps.person.gender will return the persons gender.
But when options is called for the client, this.props is passed, which at that point does not yet contain the person prop, and thus accessing ownProps.person.gender will fail with an error.
Intended outcome:
For the client, options should also be called with the value of nextProps
Actual outcome:
App throws an error: Uncaught TypeError: Cannot read property 'gender' of undefined
How to reproduce the issue:
I've created a minimal example demonstrating the issue using the error-template (note the branch):
Just run it with the developer console open and the problem will present itself.
When
skip
transitions fromtrue
tofalse
due to a prop change, theoptions
method is called several times. The times it is called to retrieve for example the variables for the query it is called with the componentsnextProps
. But the internalgetClient
method calls it withthis.props
. As this hasn't been brought up as of yet, I recon nobody has usedskip
in the way I did.Take for example this options object:
So as long as there's no
person
property available I don't want to execute the query.But the moment the
person
property is set,options
is called several times. Not sure of the order, but at least forskip
,variables
andclient
. When it is called forskip
orvariables
, thenextProps
are passed, andownProps.person.gender
will return the persons gender.But when options is called for the client,
this.props
is passed, which at that point does not yet contain theperson
prop, and thus accessingownProps.person.gender
will fail with an error.Intended outcome:
For the client,
options
should also be called with the value ofnextProps
Actual outcome:
App throws an error:
Uncaught TypeError: Cannot read property 'gender' of undefined
How to reproduce the issue:
I've created a minimal example demonstrating the issue using the error-template (note the branch):
Just run it with the developer console open and the problem will present itself.
https://github.com/koenpunt/react-apollo-error-template/tree/get-client-prev-props
Version
The text was updated successfully, but these errors were encountered: