diff --git a/src/components/createConnect.js b/src/components/createConnect.js
index a22ada650..083cd9ba0 100644
--- a/src/components/createConnect.js
+++ b/src/components/createConnect.js
@@ -90,6 +90,8 @@ export default function createConnect(React) {
shouldComponentUpdate(nextProps, nextState) {
if (!pure) {
+ this.updateStateProps(nextProps);
+ this.updateDispatchProps(nextProps);
this.updateState(nextProps);
return true;
}
diff --git a/test/components/connect.spec.js b/test/components/connect.spec.js
index 30741853f..5deb23ab4 100644
--- a/test/components/connect.spec.js
+++ b/test/components/connect.spec.js
@@ -1148,6 +1148,65 @@ describe('React', () => {
expect(target.props.statefulValue).toEqual(1);
});
+ it('calls mapState and mapDispatch for impure components', () => {
+ const store = createStore(() => ({
+ foo: 'foo',
+ bar: 'bar'
+ }));
+
+ const mapStateSpy = expect.createSpy();
+ const mapDispatchSpy = expect.createSpy().andReturn({});
+
+ class ImpureComponent extends Component {
+ render() {
+ return ;
+ }
+ }
+
+ const decorator = connect(
+ (state, {storeGetter}) => {
+ mapStateSpy();
+ return {value: state[storeGetter.storeKey]};
+ },
+ mapDispatchSpy,
+ null,
+ { pure: false }
+ );
+ const Decorated = decorator(ImpureComponent);
+
+ class StatefulWrapper extends Component {
+ state = {
+ storeGetter: {storeKey: 'foo'}
+ };
+
+ render() {
+ return ;
+ };
+ }
+
+ const tree = TestUtils.renderIntoDocument(
+
+
+
+ );
+
+ const target = TestUtils.findRenderedComponentWithType(tree, Passthrough);
+ const wrapper = TestUtils.findRenderedComponentWithType(tree, StatefulWrapper);
+
+ expect(mapStateSpy.calls.length).toBe(2);
+ expect(mapDispatchSpy.calls.length).toBe(2);
+ expect(target.props.statefulValue).toEqual('foo');
+
+ // Impure update
+ const storeGetter = wrapper.state.storeGetter;
+ storeGetter.storeKey = 'bar';
+ wrapper.setState({ storeGetter });
+
+ expect(mapStateSpy.calls.length).toBe(3);
+ expect(mapDispatchSpy.calls.length).toBe(3);
+ expect(target.props.statefulValue).toEqual('bar');
+ });
+
it('should pass state consistently to mapState', () => {
const store = createStore(stringBuilder);