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

(筆記)reduxjs / reselect #124

Open
gracekrcx opened this issue Nov 1, 2021 · 0 comments
Open

(筆記)reduxjs / reselect #124

gracekrcx opened this issue Nov 1, 2021 · 0 comments

Comments

@gracekrcx
Copy link
Owner

Reselect

Reselect 是一個簡單的 library 可以用來建立會自動記憶、可組合的 selector function。可以用 Reselect 的 selector 來有效率的從 Redux store 計算衍生資料。

使用 Memoized Selector 的動機

缺點:在每次 component 更新的時候都會計算 todos。如果 state tree 很大,或是計算的代價很大,在每次更新的時候重複計算可能會造成效能問題。Reselect 可以幫助我們避免這些不需要的重複計算。

備註

大部分 Redux 專案遇到因太多衍生運算和浪費地重複 render 而造成效能問題時,都已開始使用 Reselect 。所以在你開始建構某些大專案前確保你已熟悉它。讀它的原始碼也很有幫助,這讓你不會覺得它很神奇。

參考文章:
計算衍生資料

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

No branches or pull requests

1 participant