Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stale props and zombie children in Redux #5

Open
arthur791004 opened this issue Mar 24, 2020 · 0 comments
Open

Stale props and zombie children in Redux #5

arthur791004 opened this issue Mar 24, 2020 · 0 comments

Comments

@arthur791004
Copy link
Owner

Referneces

https://kaihao.dev/posts/Stale-props-and-zombie-children-in-Redux

Feedbacks

解決問題

  • Zombie Children
    • 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

延伸問題

Further Readings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant