File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 58
58
"webpack" : " ^1.11.0"
59
59
},
60
60
"dependencies" : {
61
+ "hoist-non-react-statics" : " ^1.0.3" ,
61
62
"invariant" : " ^2.0.0"
62
63
},
63
64
"peerDependencies" : {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import createStoreShape from '../utils/createStoreShape';
2
2
import shallowEqual from '../utils/shallowEqual' ;
3
3
import isPlainObject from '../utils/isPlainObject' ;
4
4
import wrapActionCreators from '../utils/wrapActionCreators' ;
5
+ import hoistStatics from 'hoist-non-react-statics' ;
5
6
import invariant from 'invariant' ;
6
7
7
8
const defaultMapStateToProps = ( ) => ( { } ) ;
@@ -232,7 +233,7 @@ export default function createConnect(React) {
232
233
} ;
233
234
}
234
235
235
- return Connect ;
236
+ return hoistStatics ( Connect , WrappedComponent ) ;
236
237
} ;
237
238
} ;
238
239
}
Original file line number Diff line number Diff line change @@ -1021,6 +1021,24 @@ describe('React', () => {
1021
1021
expect ( decorated . WrappedComponent ) . toBe ( Container ) ;
1022
1022
} ) ;
1023
1023
1024
+ it ( 'should hoist non-react statics from wrapped component' , ( ) => {
1025
+ class Container extends Component {
1026
+ static howIsRedux = ( ) => 'Awesome!' ;
1027
+ static foo = 'bar' ;
1028
+
1029
+ render ( ) {
1030
+ return < Passthrough /> ;
1031
+ }
1032
+ }
1033
+
1034
+ const decorator = connect ( state => state ) ;
1035
+ const decorated = decorator ( Container ) ;
1036
+
1037
+ expect ( decorated . howIsRedux ) . toBeA ( 'function' ) ;
1038
+ expect ( decorated . howIsRedux ( ) ) . toBe ( 'Awesome!' ) ;
1039
+ expect ( decorated . foo ) . toBe ( 'bar' ) ;
1040
+ } ) ;
1041
+
1024
1042
it ( 'should use the store from the props instead of from the context if present' , ( ) => {
1025
1043
class Container extends Component {
1026
1044
render ( ) {
You can’t perform that action at this time.
0 commit comments