Skip to content

Commit

Permalink
bugfix: fix the issue where getters are not updated after state has u…
Browse files Browse the repository at this point in the history
…pdated
  • Loading branch information
Prakhar Pal committed Mar 20, 2022
1 parent b84e967 commit 55cd3f8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ export default (
...this.mappedGetters,
};

if (this.mappedState) {
if (this.mappedState || this.mappedGetters) {
this.unsubscribeFn = this.store.subscribe((mutation, state) => {
let newState = {};
// update state from store state
const newMappedState = mapStateToPropsFn(state, this.props);
const newMappedState = mapStateToPropsFn && mapStateToPropsFn(state, this.props);
if (!shallowEqual(this.mappedState, newMappedState)) {
this.mappedState = newMappedState;
newState = { ...newState, ...this.mappedState };
}

// update state from store getters, if any
if (this.mappedGetters) {
const newMappedGetters = mapGetterToPropsFn(this.store.getters, this.props);
const newMappedGetters = mapGetterToPropsFn && mapGetterToPropsFn(this.store.getters, this.props);
if (!shallowEqual(this.mappedGetters, newMappedGetters)) {
this.mappedGetters = newMappedGetters;
newState = { ...newState, ...this.mappedGetters };
Expand Down

0 comments on commit 55cd3f8

Please sign in to comment.