You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you trigger mapStateToProps inside the callback of store.subscribe, if you delete an item in todo list, you would get an error 💥 because children subscribe store first
Solve: move mapStateToProps outside store.subscribe which means trigger it when every render. Then you would get top-down updates without errors
When you use setTimeout in event callbacks (ex. click) to delete an item, you would get an error 💥
setState is in fact asynchronous, as long as the setState call is inside React event handler callback
Solve: unstable_batchedUpdates
如何運作
Nested subscriptions model - monkey patching store.subscribe
Referneces
https://kaihao.dev/posts/Stale-props-and-zombie-children-in-Redux
Feedbacks
解決問題
mapStateToProps
inside the callback ofstore.subscribe
, if you delete an item in todo list, you would get an error 💥 because children subscribe store firstmapStateToProps
outsidestore.subscribe
which means trigger it when every render. Then you would get top-down updates without errorssetTimeout
in event callbacks (ex. click) to delete an item, you would get an error 💥如何運作
store.subscribe
延伸問題
Further Readings
The text was updated successfully, but these errors were encountered: