We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7b39928 commit 9a8d050Copy full SHA for 9a8d050
src/components/Provider.js
@@ -40,12 +40,25 @@ export function createProvider(storeKey = 'store') {
40
this.subscribe();
41
}
42
43
+ componentWillUnmount() {
44
+ if(this.unsubscribe) {
45
+ this.unsubscribe()
46
+ this._isMounted = false;
47
+ }
48
49
+
50
subscribe() {
51
const {store} = this.props;
52
53
+ this._isMounted = true;
54
55
this.unsubscribe = store.subscribe( () => {
56
const newStoreState = store.getState();
57
58
+ if(!this._isMounted) {
59
+ return;
60
61
62
this.setState(providerState => {
63
// If the value is the same, skip the unnecessary state update.
64
if(providerState.storeState === newStoreState) {
0 commit comments