1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Clarify usage of connect in README.md (#2845)

Added a quick example of how to use `connect` in `react-redux` as there are no examples in this example.
This commit is contained in:
Julian Wilson 2017-08-27 14:56:52 -04:00 committed by Tim Neutkens
parent 75a43f5a71
commit b543795fc0

View file

@ -24,4 +24,17 @@ now
```
## The idea behind the example
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.
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.
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:
```js
const mapStateToProps = state => ({
location: state.form.location,
});
export default withData(connect(mapStateToProps, null)(Index));
```
`connect` must go inside `withData` otherwise `connect` will not be able to find the store.