React-apollo: Wrong props passed to `mapQueriesToProps` and `mapMutationsToProps` on store change

Created on 6 Jun 2016  路  5Comments  路  Source: apollographql/react-apollo

In connect's bindStoreUpdate method, this.props is bound only once:

https://github.com/apollostack/react-apollo/blob/69ce020acbc6b21e43def5e1eca1f36f263e353f/src/connect.tsx#L202

Whenever this.subscribeToAllQueries and this.createAllMutationHandlers are called further down in this method due to store state changes, they receive the probably outdated props bound on initialisation instead of the current value of this.props.

Should I prepare a pull request to fix this?

bug

Most helpful comment

@jbaxleyiii I created a minimal test that replicates the behavior; the test fails at line 79 where the original prop value "foo" is passed to mapQueriesToProps again despite not actually having been changed:

https://gist.github.com/sgoll/8519d638feb9489242f517cf954e4681

All 5 comments

@sgoll do you have a replication that shows the outdated props? We have a few tests to ensure that the correct props are passed to the map functions

@jbaxleyiii Yep, it happens in our current project, which isn't even too complicated (basic Redux store and react-router). I'll write up a minimal example tonight.

@jbaxleyiii I created a minimal test that replicates the behavior; the test fails at line 79 where the original prop value "foo" is passed to mapQueriesToProps again despite not actually having been changed:

https://gist.github.com/sgoll/8519d638feb9489242f517cf954e4681

@sgoll fantastic replication! I'll take a look and try to get a fix out today!

Also thanks so much @sgoll for the fantastic test reproduction!

Fixed via https://github.com/apollostack/react-apollo/pull/70 in 0.3.8

Was this page helpful?
0 / 5 - 0 ratings