@@ -11,6 +11,9 @@ const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({
1111 ...stateProps ,
1212 ...dispatchProps
1313} ) ;
14+ const defaultOptions = {
15+ pure : true
16+ } ;
1417
1518function getDisplayName ( Component ) {
1619 return Component . displayName || Component . name || 'Component' ;
@@ -23,7 +26,7 @@ export default function createConnect(React) {
2326 const { Component, PropTypes } = React ;
2427 const storeShape = createStoreShape ( PropTypes ) ;
2528
26- return function connect ( mapStateToProps , mapDispatchToProps , mergeProps ) {
29+ return function connect ( mapStateToProps , mapDispatchToProps , mergeProps , options ) {
2730 const shouldSubscribe = Boolean ( mapStateToProps ) ;
2831 const finalMapStateToProps = mapStateToProps || defaultMapStateToProps ;
2932 const finalMapDispatchToProps = isPlainObject ( mapDispatchToProps ) ?
@@ -32,6 +35,7 @@ export default function createConnect(React) {
3235 const finalMergeProps = mergeProps || defaultMergeProps ;
3336 const shouldUpdateStateProps = finalMapStateToProps . length > 1 ;
3437 const shouldUpdateDispatchProps = finalMapDispatchToProps . length > 1 ;
38+ const finalOptions = { ...defaultOptions , ...options } || defaultOptions ;
3539
3640 // Helps track hot reloading.
3741 const version = nextVersion ++ ;
@@ -88,7 +92,7 @@ export default function createConnect(React) {
8892 } ;
8993
9094 shouldComponentUpdate ( nextProps , nextState ) {
91- return ! shallowEqual ( this . state . props , nextState . props ) ;
95+ return ! finalOptions . pure || ! shallowEqual ( this . state . props , nextState . props ) ;
9296 }
9397
9498 constructor ( props , context ) {
0 commit comments