File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 5858 "webpack" : " ^1.11.0"
5959 },
6060 "dependencies" : {
61+ "hoist-non-react-statics" : " ^1.0.3" ,
6162 "invariant" : " ^2.0.0"
6263 },
6364 "peerDependencies" : {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import createStoreShape from '../utils/createStoreShape';
22import shallowEqual from '../utils/shallowEqual' ;
33import isPlainObject from '../utils/isPlainObject' ;
44import wrapActionCreators from '../utils/wrapActionCreators' ;
5+ import hoistStatics from 'hoist-non-react-statics' ;
56import invariant from 'invariant' ;
67
78const defaultMapStateToProps = ( ) => ( { } ) ;
@@ -232,7 +233,7 @@ export default function createConnect(React) {
232233 } ;
233234 }
234235
235- return Connect ;
236+ return hoistStatics ( Connect , WrappedComponent ) ;
236237 } ;
237238 } ;
238239}
Original file line number Diff line number Diff line change @@ -1021,6 +1021,24 @@ describe('React', () => {
10211021 expect ( decorated . WrappedComponent ) . toBe ( Container ) ;
10221022 } ) ;
10231023
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+
10241042 it ( 'should use the store from the props instead of from the context if present' , ( ) => {
10251043 class Container extends Component {
10261044 render ( ) {
You can’t perform that action at this time.
0 commit comments