Skip to content

Commit ce6ce7c

Browse files
committed
Clarify that connect() result should be used
1 parent 098551f commit ce6ce7c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ React.render(
230230

231231
Connects a React component to a Redux store.
232232

233+
It does not modify the component class passed to it.
234+
Instead, it *returns* a new, connected component class, for you to use.
235+
233236
#### Arguments
234237

235238
* [`mapStateToProps(state, [ownProps]): stateProps`] \(*Function*): If specified, the component will subscribe to Redux store updates. Any time it updates, `mapStateToProps` will be called. Its result must be a plain object, and it will be merged into the component’s props. If you omit it, the component will not be subscribed to the Redux store. If `ownProps` is specified as a second argument, then `mapStateToProps` will be re-invoked whenever the component receives new props.
@@ -246,6 +249,8 @@ A React component class that injects state and action creators into your compone
246249

247250
* It needs to be invoked two times. The first time with its arguments described above, and a second time, with the component: `connect(mapStateToProps, mapDispatchToProps, mergeProps)(MyComponent)`.
248251

252+
* It does not modify the passed React component. It returns a new, connected component, that you should use instead.
253+
249254
* The `mapStateToProps` function takes a single argument of the entire Redux store’s state and returns an object to be passed as props. It is often called a **selector**. Use [reselect](https://github.com/faassen/reselect) to efficiently compose selectors and [compute derived data](http://gaearon.github.io/redux/docs/recipes/ComputingDerivedData.html).
250255

251256
* **To use `connect()`, the root component of your app must be wrapped into `<Provider>{() => ... }</Provider>` before being rendered.** You may also pass `store` as a prop to the `connect()`ed component, but it's not recommended, because it's just too much trouble. Only do this for non-fully-React codebases or to stub the store in a unit test.

0 commit comments

Comments
 (0)