You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -241,6 +241,10 @@ Instead, it *returns* a new, connected component class, for you to use.
241
241
242
242
*[`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.
243
243
244
+
*[`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`.*
247
+
244
248
#### Returns
245
249
246
250
A React component class that injects state and action creators into your component according to the specified options.
@@ -460,6 +464,30 @@ render() {
460
464
Conveniently, this gives your components access to the router state!
461
465
You can also upgrade to React Router 1.0 which shouldn’t have this problem. (Let us know if it does!)
462
466
467
+
### My views aren't updating when something changes outside of Redux
468
+
469
+
If your views depend on global state or context, you might find that views decorated with `connect()` will fail to update.
470
+
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).
472
+
473
+
The _best_ solution to this is to make your components 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.
474
+
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()`:
0 commit comments