Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"webpack": "^1.11.0"
},
"dependencies": {
"hoist-non-react-statics": "^1.0.3",
"invariant": "^2.0.0"
},
"peerDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion src/components/createConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import createStoreShape from '../utils/createStoreShape';
import shallowEqual from '../utils/shallowEqual';
import isPlainObject from '../utils/isPlainObject';
import wrapActionCreators from '../utils/wrapActionCreators';
import hoistStatics from 'hoist-non-react-statics';
import invariant from 'invariant';

const defaultMapStateToProps = () => ({});
Expand Down Expand Up @@ -232,7 +233,7 @@ export default function createConnect(React) {
};
}

return Connect;
return hoistStatics(Connect, WrappedComponent);
};
};
}
18 changes: 18 additions & 0 deletions test/components/connect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,24 @@ describe('React', () => {
expect(decorated.WrappedComponent).toBe(Container);
});

it('should hoist non-react statics from wrapped component', () => {
class Container extends Component {
static howIsRedux = () => 'Awesome!';
static foo = 'bar';

render() {
return <Passthrough />;
}
}

const decorator = connect(state => state);
const decorated = decorator(Container);

expect(decorated.howIsRedux).toBeA('function');
expect(decorated.howIsRedux()).toBe('Awesome!');
expect(decorated.foo).toBe('bar');
});

it('should use the store from the props instead of from the context if present', () => {
class Container extends Component {
render() {
Expand Down