From 55cd3f873c0770f5ea7d9c08ea4d8e19bf40cf76 Mon Sep 17 00:00:00 2001 From: Prakhar Pal Date: Mon, 21 Mar 2022 01:30:13 +0530 Subject: [PATCH] bugfix: fix the issue where getters are not updated after state has updated --- src/components/connect.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/connect.js b/src/components/connect.js index 0776419..d864d2b 100644 --- a/src/components/connect.js +++ b/src/components/connect.js @@ -29,11 +29,11 @@ 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 }; @@ -41,7 +41,7 @@ export default ( // 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 };