Skip to content

Commit 7831b92

Browse files
committed
Update README.md
1 parent cde6123 commit 7831b92

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ Instead, it *returns* a new, connected component class, for you to use.
242242
* [`mergeProps(stateProps, dispatchProps, ownProps): props`] \(*Function*): If specified, it is passed the result of `mapStateToProps()`, `mapDispatchToProps()`, and the parent `props`. The plain object you return from it will be passed as props to the wrapped component. You may specify this function to select a slice of the state based on props, or to bind action creators to a particular variable from props. If you omit it, `Object.assign({}, ownProps, stateProps, dispatchProps)` is used by default.
243243

244244
* [`options`] *(Object)* If specified, further customizes the behavior of the connector.
245-
246-
* [`pure`] *(Boolean)*: If true, implements `shouldComponentUpdate` and shallowly compares the result of `mergeProps`, preventing unnecessary updates, assuming that the component is a "pure" component and does not rely on any input or state other than its props and the Redux store. *Defaults to `true`.*
245+
* [`pure`] *(Boolean)*: If true, implements `shouldComponentUpdate` and shallowly compares the result of `mergeProps`, preventing unnecessary updates, assuming that the component is a “pure” component and does not rely on any input or state other than its props and the selected Redux store’s state. *Defaults to `true`.*
247246

248247
#### Returns
249248

@@ -466,27 +465,25 @@ You can also upgrade to React Router 1.0 which shouldn’t have this problem. (L
466465

467466
### My views aren't updating when something changes outside of Redux
468467

469-
If your views depend on global state or context, you might find that views decorated with `connect()` will fail to update.
468+
If your views depend on global state or [React “context](www.youtube.com/watch?v=H7vlH-wntD4), you might find that views decorated with `connect()` will fail to update.
470469

471-
> This is because `connect()` implements [shouldComponentUpdate](https://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate) by default, assuming that your component will produce the same results given the same props and state. This is a similar concept to React's [PureRenderMixin](https://facebook.github.io/react/docs/pure-render-mixin.html).
470+
>This is because `connect()` implements [shouldComponentUpdate](https://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate) by default, assuming that your component will produce the same results given the same props and state. This is a similar concept to React's [PureRenderMixin](https://facebook.github.io/react/docs/pure-render-mixin.html).
472471
473472
The _best_ solution to this is to make sure that your components are pure and pass any external state to them via props. This will ensure that your views do not re-render unless they actually need to re-render and will greatly speed up your application.
474473

475-
If that's not practical for whatever reason (for example, if you're using a library that depends heavily on Context), you can pass the `pure: false` option to `connect()`:
474+
If that's not practical for whatever reason (for example, if youre using a library that depends heavily on React context), you may pass the `pure: false` option to `connect()`:
476475

477476
```
478477
function mapStateToProps(state) {
479478
return { todos: state.todos };
480479
}
481480
482-
const options = {
481+
export default connect(mapStateToProps, null, null, {
483482
pure: false
484-
};
485-
486-
export default connect(mapStateToProps, null, null, options)(TodoApp);
483+
})(TodoApp);
487484
```
488485

489-
This will remove the assumption that `TodoApp` is pure and cause it to update whenever its parent component renders.
486+
This will remove the assumption that `TodoApp` is pure and cause it to update whenever its parent component renders. Note that this will make your application less performant, so only do this if you have no other option.
490487

491488
### Could not find "store" in either the context or props
492489

0 commit comments

Comments
 (0)