-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Don't recommend memoizing selectors #1707
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As per the discussions below, memoizing selectors does not improve performance significantly as of v4. Thus we should avoid recommending selector memoization. Note that the same paragraph was removed from the README in PR #550 (#550) and this section may have been left behind as an oversight. - #658 - #971
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e7f2b46:
|
dai-shi
approved these changes
Mar 22, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
bodinsamuel
referenced
this pull request
in specfy/specfy
Jul 8, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [zustand](https://github.com/pmndrs/zustand) | [`4.3.6` -> `4.3.9`](https://renovatebot.com/diffs/npm/zustand/4.3.6/4.3.9) | [![age](https://badges.renovateapi.com/packages/npm/zustand/4.3.9/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/zustand/4.3.9/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/zustand/4.3.9/compatibility-slim/4.3.6)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/zustand/4.3.9/confidence-slim/4.3.6)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>pmndrs/zustand (zustand)</summary> ### [`v4.3.9`](https://github.com/pmndrs/zustand/releases/tag/v4.3.9) [Compare Source](https://github.com/pmndrs/zustand/compare/v4.3.8...v4.3.9) This includes a small improvement for production build mostly for Vite users. Docs have been improved too! #### What's Changed - fix(build): mode env for "import" condition" by [@​dai-shi](https://github.com/dai-shi) in [https://github.com/pmndrs/zustand/pull/1845](https://github.com/pmndrs/zustand/pull/1845) #### New Contributors - [@​Debbl](https://github.com/Debbl) made their first contribution in [https://github.com/pmndrs/zustand/pull/1792](https://github.com/pmndrs/zustand/pull/1792) - [@​Nipodemos](https://github.com/Nipodemos) made their first contribution in [https://github.com/pmndrs/zustand/pull/1782](https://github.com/pmndrs/zustand/pull/1782) - [@​vadimshvetsov](https://github.com/vadimshvetsov) made their first contribution in [https://github.com/pmndrs/zustand/pull/1800](https://github.com/pmndrs/zustand/pull/1800) - [@​bobylito](https://github.com/bobylito) made their first contribution in [https://github.com/pmndrs/zustand/pull/1810](https://github.com/pmndrs/zustand/pull/1810) - [@​celineling](https://github.com/celineling) made their first contribution in [https://github.com/pmndrs/zustand/pull/1804](https://github.com/pmndrs/zustand/pull/1804) - [@​valerii15298](https://github.com/valerii15298) made their first contribution in [https://github.com/pmndrs/zustand/pull/1819](https://github.com/pmndrs/zustand/pull/1819) - [@​Hecmatyar](https://github.com/Hecmatyar) made their first contribution in [https://github.com/pmndrs/zustand/pull/1816](https://github.com/pmndrs/zustand/pull/1816) - [@​203x](https://github.com/203x) made their first contribution in [https://github.com/pmndrs/zustand/pull/1826](https://github.com/pmndrs/zustand/pull/1826) - [@​Ciensprog](https://github.com/Ciensprog) made their first contribution in [https://github.com/pmndrs/zustand/pull/1844](https://github.com/pmndrs/zustand/pull/1844) - [@​Romainlg29](https://github.com/Romainlg29) made their first contribution in [https://github.com/pmndrs/zustand/pull/1843](https://github.com/pmndrs/zustand/pull/1843) - [@​dcorb](https://github.com/dcorb) made their first contribution in [https://github.com/pmndrs/zustand/pull/1847](https://github.com/pmndrs/zustand/pull/1847) - [@​ivoilic](https://github.com/ivoilic) made their first contribution in [https://github.com/pmndrs/zustand/pull/1856](https://github.com/pmndrs/zustand/pull/1856) - [@​Kiku-CN](https://github.com/Kiku-CN) made their first contribution in [https://github.com/pmndrs/zustand/pull/1889](https://github.com/pmndrs/zustand/pull/1889) - [@​LartyHD](https://github.com/LartyHD) made their first contribution in [https://github.com/pmndrs/zustand/pull/1893](https://github.com/pmndrs/zustand/pull/1893) - [@​ChoiHyunjin](https://github.com/ChoiHyunjin) made their first contribution in [https://github.com/pmndrs/zustand/pull/1903](https://github.com/pmndrs/zustand/pull/1903) - [@​thesuryavivek](https://github.com/thesuryavivek) made their first contribution in [https://github.com/pmndrs/zustand/pull/1906](https://github.com/pmndrs/zustand/pull/1906) - [@​thedipankarroy](https://github.com/thedipankarroy) made their first contribution in [https://github.com/pmndrs/zustand/pull/1913](https://github.com/pmndrs/zustand/pull/1913) **Full Changelog**: pmndrs/zustand@v4.3.8...v4.3.9 ### [`v4.3.8`](https://github.com/pmndrs/zustand/releases/tag/v4.3.8) [Compare Source](https://github.com/pmndrs/zustand/compare/v4.3.7...v4.3.8) For persist middleware, a new option for createJSONStorage in introduced to support more cases. Note that createJSONStorage isn't a required function (and it's not very recommended as it's not type safe), and one should create a custom storage for more use cases. #### What's Changed - chore: add extension in imports by [@​dai-shi](https://github.com/dai-shi) in [https://github.com/pmndrs/zustand/pull/1678](https://github.com/pmndrs/zustand/pull/1678) - feat(middleware/persist): improve createJSONStorage for Maps by [@​lauhon](https://github.com/lauhon) in [https://github.com/pmndrs/zustand/pull/1763](https://github.com/pmndrs/zustand/pull/1763) - chore(tests): migrate to vitest by [@​arjunvegda](https://github.com/arjunvegda) in [https://github.com/pmndrs/zustand/pull/1753](https://github.com/pmndrs/zustand/pull/1753) #### New Contributors - [@​JacobWeisenburger](https://github.com/JacobWeisenburger) made their first contribution in [https://github.com/pmndrs/zustand/pull/1737](https://github.com/pmndrs/zustand/pull/1737) - [@​spacemeowx2](https://github.com/spacemeowx2) made their first contribution in [https://github.com/pmndrs/zustand/pull/1742](https://github.com/pmndrs/zustand/pull/1742) - [@​arjunvegda](https://github.com/arjunvegda) made their first contribution in [https://github.com/pmndrs/zustand/pull/1754](https://github.com/pmndrs/zustand/pull/1754) - [@​zc627788](https://github.com/zc627788) made their first contribution in [https://github.com/pmndrs/zustand/pull/1752](https://github.com/pmndrs/zustand/pull/1752) - [@​arvinxx](https://github.com/arvinxx) made their first contribution in [https://github.com/pmndrs/zustand/pull/1758](https://github.com/pmndrs/zustand/pull/1758) - [@​SilentFlute](https://github.com/SilentFlute) made their first contribution in [https://github.com/pmndrs/zustand/pull/1762](https://github.com/pmndrs/zustand/pull/1762) - [@​dannobytes](https://github.com/dannobytes) made their first contribution in [https://github.com/pmndrs/zustand/pull/1779](https://github.com/pmndrs/zustand/pull/1779) - [@​BLooDBRothER](https://github.com/BLooDBRothER) made their first contribution in [https://github.com/pmndrs/zustand/pull/1777](https://github.com/pmndrs/zustand/pull/1777) - [@​lauhon](https://github.com/lauhon) made their first contribution in [https://github.com/pmndrs/zustand/pull/1763](https://github.com/pmndrs/zustand/pull/1763) **Full Changelog**: pmndrs/zustand@v4.3.7...v4.3.8 ### [`v4.3.7`](https://github.com/pmndrs/zustand/releases/tag/v4.3.7) [Compare Source](https://github.com/pmndrs/zustand/compare/v4.3.6...v4.3.7) This includes a couple of improvements in `persist` middleware. #### What's Changed - feat(middleware/persist): add skip hydration option [#​405](https://github.com/pmndrs/zustand/issues/405) by [@​gmanninglive](https://github.com/gmanninglive) in [https://github.com/pmndrs/zustand/pull/1647](https://github.com/pmndrs/zustand/pull/1647) - fix(middleware/persist): ensure `persist` does not drop updates in `onRehydrateStorage` when using a synchronous storage API by [@​coffeebeats](https://github.com/coffeebeats) in [https://github.com/pmndrs/zustand/pull/1689](https://github.com/pmndrs/zustand/pull/1689) - fix(middleware/persist): ensure argument for `onRehydrateStorage` and `onHydrate` is defined on first hydration by [@​coffeebeats](https://github.com/coffeebeats) in [https://github.com/pmndrs/zustand/pull/1692](https://github.com/pmndrs/zustand/pull/1692) #### New Contributors - [@​hi-otto](https://github.com/hi-otto) made their first contribution in [https://github.com/pmndrs/zustand/pull/1687](https://github.com/pmndrs/zustand/pull/1687) - [@​pastelmind](https://github.com/pastelmind) made their first contribution in [https://github.com/pmndrs/zustand/pull/1707](https://github.com/pmndrs/zustand/pull/1707) - [@​gmanninglive](https://github.com/gmanninglive) made their first contribution in [https://github.com/pmndrs/zustand/pull/1647](https://github.com/pmndrs/zustand/pull/1647) - [@​coffeebeats](https://github.com/coffeebeats) made their first contribution in [https://github.com/pmndrs/zustand/pull/1689](https://github.com/pmndrs/zustand/pull/1689) **Full Changelog**: pmndrs/zustand@v4.3.6...v4.3.7 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 4pm on friday,before 9am on monday,every weekend" in timezone Europe/Paris, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/specfy/specfy). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTkuNyIsInVwZGF0ZWRJblZlciI6IjM1LjE1OS43IiwidGFyZ2V0QnJhbmNoIjoiY2hvcmUvcmVub3ZhdGVCYXNlQnJhbmNoIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issues or Discussions
Summary
As per the discussions above, memoizing selectors does not improve performance significantly as of v4. Thus we should not recommend memoizing selectors.
Note that the same paragraph was removed from the README in #550 and this section may have been left behind as an oversight.
P. S. I wish the docs stated "selectors do not benefit significantly from memoization". I feel this doesn't belong in the Recipes page, though; perhaps a FAQ section is needed?
Check List
yarn run prettier
for formatting code and docs