@@ -11,6 +11,9 @@ const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({
11
11
...stateProps ,
12
12
...dispatchProps
13
13
} ) ;
14
+ const defaultOptions = {
15
+ pure : true
16
+ } ;
14
17
15
18
function getDisplayName ( Component ) {
16
19
return Component . displayName || Component . name || 'Component' ;
@@ -23,7 +26,7 @@ export default function createConnect(React) {
23
26
const { Component, PropTypes } = React ;
24
27
const storeShape = createStoreShape ( PropTypes ) ;
25
28
26
- return function connect ( mapStateToProps , mapDispatchToProps , mergeProps ) {
29
+ return function connect ( mapStateToProps , mapDispatchToProps , mergeProps , options ) {
27
30
const shouldSubscribe = Boolean ( mapStateToProps ) ;
28
31
const finalMapStateToProps = mapStateToProps || defaultMapStateToProps ;
29
32
const finalMapDispatchToProps = isPlainObject ( mapDispatchToProps ) ?
@@ -32,6 +35,7 @@ export default function createConnect(React) {
32
35
const finalMergeProps = mergeProps || defaultMergeProps ;
33
36
const shouldUpdateStateProps = finalMapStateToProps . length > 1 ;
34
37
const shouldUpdateDispatchProps = finalMapDispatchToProps . length > 1 ;
38
+ const finalOptions = { ...defaultOptions , ...options } || defaultOptions ;
35
39
36
40
// Helps track hot reloading.
37
41
const version = nextVersion ++ ;
@@ -88,7 +92,7 @@ export default function createConnect(React) {
88
92
} ;
89
93
90
94
shouldComponentUpdate ( nextProps , nextState ) {
91
- return ! shallowEqual ( this . state . props , nextState . props ) ;
95
+ return ! finalOptions . pure || ! shallowEqual ( this . state . props , nextState . props ) ;
92
96
}
93
97
94
98
constructor ( props , context ) {
0 commit comments