Issue when using @graphql decorator + Redux [2.0]
See original GitHub issueIntended outcome:
After just upgrading to 2.0 from the beta, I expected that wrapping a GraphQL-decorated class with Redux’s connect()
method should continue to work like before. For example:
@graph(MY_QUERY, { ...
class MyComponent {
// ....
export default connect(mapStateToProps)(MyComponent)
Actual outcome: Now, I am getting the following error:
Could not find "store" in either the context or props of "Connect(Apollo(MyComponent))". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(Apollo(MyComponent))"
I’m wrapping my root app class in an <ApolloProvider>
tag, and was previously passing in my Redux store as a store
prop. This was all working, however, after the non-beta upgrade this error began to appear. I suspect it is because the new client has officially removed certain Redux props and methods due to dropping it as a dependency, but I’m not entirely certain. Any insight would be greatly appreciated. Thanks.
Version
- apollo-client@2.0.1
- react-apollo@2.0.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Decouple GraphQL store with a generic API #1432 - GitHub
I am using ngRX already and really love it, it feels like the right redux-style store for Angular apps. I am just starting...
Read more >How to update the Redux store after Apollo GraphQL query ...
I'm displaying the list in a controlled radio button group and I need to select one of the items by default. The id...
Read more >Integrate TypeScript with GraphQL using TypeGraphQL
The Field decorator is used to declare the class properties that should be mapped to the GraphQL fields. It is also used to...
Read more >react-apollo-decorators - npm package - Snyk
Use this decorator to make GraphQL query . Differences with apollo's graphql decorator: Props will be directly passed to query variables (filtering which...
Read more >Build React forms based on GraphQL APIs. | by Charly Poly
Like everybody in the “React world”, I heavily used redux-form on my current company big SPA, even after the migration from REST API...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is not a bug. You need to use Provider from react-redux. Apollo 2.0 is not using redux anymore.
I just encountered this also. It wasn’t an issue after upgrading to Apollo 2.0 but I made some changes to my router, and now some pages work and some don’t, throwing this error.
I had issues with
ConnectedRouter
from react-router-redux@5, which lead me to move the store off<ApolloProvider />
and onto<ConnectedRouter />
. Now that is causing a problem because my SignIn View is hooked to Redux:The recommendation above solves my issues across the board.
Here is my functional setup:
If you haven’t used ConnectedRouter before, it’s pretty dope. It allows you to navigate using Redux because of some helper methods it installs. I enjoy having access to
this.props.dispatch(push('SomeView'))
andthis.props.dispatch(goBack())
. Those are situationally useful, robust addons, but you can also call them from action creators and instantly transition through views while they are loading without any flickering crap and without any nasty state transition errors if logic is in-flight when you do so.Using it also brings React web more in-line with React Native and react-navigation, so I like the parity. I figured I would just expand a bit on ConnectedRouter since it’s not the most common and it requires adding
@5
when you npm install it.