Skip to content

Clarify that weakMapMemoize is the default memoization function (v5) - #762

Open
veksa wants to merge 1 commit into
reduxjs:masterfrom
veksa:docs/clarify-weakmapmemoize-default-753
Open

Clarify that weakMapMemoize is the default memoization function (v5)#762
veksa wants to merge 1 commit into
reduxjs:masterfrom
veksa:docs/clarify-weakmapmemoize-default-753

Conversation

@veksa

@veksa veksa commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Closes #753

I was reading through the API docs and hit the same confusion the issue describes: nowhere does it actually say that createSelector switched to weakMapMemoize by default in v5. You kind of have to already know it.

A couple of things made it worse. The createSelector examples pass memoize: weakMapMemoize and argsMemoize: weakMapMemoize explicitly, 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 was lruMemoize with 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 — createSelectorCreator and createStructuredSelector both say the args memoizer defaults to lruMemoize, which contradicts the source and the v5 summary.

So this PR:

  • Adds a short note at the top of createSelector explaining that memoize and argsMemoize both default to weakMapMemoize since v5, how that differs from the old lruMemoize cache-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.
  • Adds a note on the weakMapMemoize page saying it's the default now, and that the examples there pass memoize/argsMemoize explicitly only to show the behavior — a plain createSelector(...) already uses it.
  • Fixes the lruMemoizeweakMapMemoize default in the createSelectorCreator and createStructuredSelector type-parameter tables.

Docs only. I double-checked the real defaults against src/createSelectorCreator.ts (argsMemoize defaults to weakMapMemoize, and the exported createSelector is built with it). No example source files changed, so nothing needs regenerating, and everything passes Prettier.

@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for reselect-docs ready!

Name Link
🔨 Latest commit 2c87ddf
🔍 Latest deploy log https://app.netlify.com/projects/reselect-docs/deploys/6a6705fcfbef1d0008821acf
😎 Deploy Preview https://deploy-preview-762--reselect-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codesandbox-ci

codesandbox-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown

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.

@aryaemami59 aryaemami59 added the Documentation Improvements or additions to documentation label Jul 26, 2026
@veksa
veksa force-pushed the docs/clarify-weakmapmemoize-default-753 branch from 43218ed to 2c87ddf Compare July 27, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation unclear that weakMapMemoize is now the default memoizer

2 participants