Store is not removed from the registry in StrictMode
Closed this issue · 1 comments
Demo
Steps to reproduce
When StrictMode
is disabled
- Disable
StrictMode
- Click a few times
Click {n} times
button. - Change project.
Expected
The button should display Click 0 times
.
Current
The button displays Click 0 times
.
When StrictMode
is enabled
- Enable
StrictMode
- Click a few times
Click {n} times
button. - Change project.
Expected
The button should display Click 0 times
.
Current
The button displays Click {n} times
.
When Container
is removed from the React tree then useEffect
is triggered defined in FunctionContainer
.
There is a check to see if storeState.listeners().size
is equal to 0
before calling if (scope) registry.deleteStore(Store, scope);
.
In StrictMode
the following line
react-sweet-state/src/components/container.js
Line 176 in 0384e28
is never called because there is always one listener and it's always that listener defined below
so it looks likeunsubscribe()
is not really removing listener
react-sweet-state/src/components/container.js
Line 160 in 0384e28
Affected code
react-sweet-state/src/components/container.js
Lines 168 to 177 in 0384e28
Fixed in v2.7.2