Skip to content

Commit b543795

Browse files
mrwillistimneutkens
authored andcommitted
Clarify usage of connect in README.md (vercel#2845)
Added a quick example of how to use `connect` in `react-redux` as there are no examples in this example.
1 parent 75a43f5 commit b543795

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

examples/with-apollo-and-redux/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,17 @@ now
2424
```
2525

2626
## The idea behind the example
27-
By default, Apollo Client creates its own internal Redux store to manage queries and their results. If you are already using Redux for the rest of your app, [you can have the client integrate with your existing store instead](http://dev.apollodata.com/react/redux.html). This example is identical to the [`with-apollo`](https://github.com/zeit/next.js/tree/master/examples/with-apollo) with the exception of this Redux store integration.
27+
By default, Apollo Client creates its own internal Redux store to manage queries and their results. If you are already using Redux for the rest of your app, [you can have the client integrate with your existing store instead](http://dev.apollodata.com/react/redux.html), which is what this example does. This example is identical to the [`with-apollo`](https://github.com/zeit/next.js/tree/master/examples/with-apollo) with the exception of this Redux store integration.
28+
29+
Note that you can acesss the redux store like you normally would using `react-redux`'s `connect` as per [here](http://dev.apollodata.com/react/redux.html#using-connect). Here's a quick example:
30+
31+
```js
32+
const mapStateToProps = state => ({
33+
location: state.form.location,
34+
});
35+
36+
export default withData(connect(mapStateToProps, null)(Index));
37+
```
38+
39+
`connect` must go inside `withData` otherwise `connect` will not be able to find the store.
40+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy