Clarify that weakMapMemoize is the default memoization function (v5) - #762
Open
veksa wants to merge 1 commit into
Open
Clarify that weakMapMemoize is the default memoization function (v5)#762veksa wants to merge 1 commit into
weakMapMemoize is the default memoization function (v5)#762veksa wants to merge 1 commit into
Conversation
✅ Deploy Preview for reselect-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
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. |
veksa
force-pushed
the
docs/clarify-weakmapmemoize-default-753
branch
from
July 27, 2026 07:17
43218ed to
2c87ddf
Compare
This file contains hidden or 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
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.
Closes #753
I was reading through the API docs and hit the same confusion the issue describes: nowhere does it actually say that
createSelectorswitched toweakMapMemoizeby default in v5. You kind of have to already know it.A couple of things made it worse. The
createSelectorexamples passmemoize: weakMapMemoizeandargsMemoize: weakMapMemoizeexplicitly, so it looks like you're supposed to configure that yourself — even though it's just the default now. And if you're coming from v4 (where the default waslruMemoizewith a cache size of 1), there's no signal that the caching behavior changed under you.While digging in I also noticed two pages that flat-out state the wrong default —
createSelectorCreatorandcreateStructuredSelectorboth say the args memoizer defaults tolruMemoize, which contradicts the source and the v5 summary.So this PR:
createSelectorexplaining thatmemoizeandargsMemoizeboth default toweakMapMemoizesince v5, how that differs from the oldlruMemoizecache-of-1 behavior, why it helps (effectively unbounded, identity-keyed cache — no more "cache size of 1" surprise when a selector is called with many different args), the memory tradeoff (entries live as long as their args are referenced, then get GC'd), and that you don't need to pass these options unless you want to override them.weakMapMemoizepage saying it's the default now, and that the examples there passmemoize/argsMemoizeexplicitly only to show the behavior — a plaincreateSelector(...)already uses it.lruMemoize→weakMapMemoizedefault in thecreateSelectorCreatorandcreateStructuredSelectortype-parameter tables.Docs only. I double-checked the real defaults against
src/createSelectorCreator.ts(argsMemoizedefaults toweakMapMemoize, and the exportedcreateSelectoris built with it). No example source files changed, so nothing needs regenerating, and everything passes Prettier.