as a developer i found mention about true behavior of memoization here https://reselect.js.org/introduction/v5-summary#breaking-changes
But i found this page only after playing with reselect in sandboxes. I was confused why this example may no effect: https://reselect.js.org/api/weakmapmemoize/#examples
llm generated:
Problem
The documentation doesn't clearly state that weakMapMemoize is now the default memoization function for createSelector (changed in commit 1ffd434).
This causes confusion because:
- Examples show redundant configuration: The weakMapMemoize example and API documentation show:
const selectItemsByCategory = createSelector(
[
(state: RootState) => state.items,
(state: RootState, category: string) => category
],
(items, category) => items.filter(item => item.category === category),
{
memoize: weakMapMemoize, // ← This is already the default
argsMemoize: weakMapMemoize // ← This is also already the default
}
)
-
Developers may not realize the default changed: Those familiar with Reselect v4.x (where lruMemoize/defaultMemoize was default) may not realize the behavior has changed.
-
Migration implications unclear: The difference between lruMemoize (cache size: 1) and weakMapMemoize (unlimited cache) has significant performance and memory implications that aren't highlighted.
Suggested Improvements
-
Add a callout to the main documentation stating:
⚠️ Note: As of v5.0, weakMapMemoize is the default memoizer. Previous versions used lruMemoize with a cache size of 1.
-
Update examples to either:
- Remove the explicit
memoize/argsMemoize options (since they're redundant)
- Add comments explaining that this is showing explicit configuration but isn't necessary:
{
// These are the defaults in v5.0+, shown here for clarity:
memoize: weakMapMemoize,
argsMemoize: weakMapMemoize
}
Current Versions Affected
as a developer i found mention about true behavior of memoization here https://reselect.js.org/introduction/v5-summary#breaking-changes
But i found this page only after playing with reselect in sandboxes. I was confused why this example may no effect: https://reselect.js.org/api/weakmapmemoize/#examples
llm generated:
Problem
The documentation doesn't clearly state that
weakMapMemoizeis now the default memoization function forcreateSelector(changed in commit 1ffd434).This causes confusion because:
Developers may not realize the default changed: Those familiar with Reselect v4.x (where
lruMemoize/defaultMemoizewas default) may not realize the behavior has changed.Migration implications unclear: The difference between
lruMemoize(cache size: 1) andweakMapMemoize(unlimited cache) has significant performance and memory implications that aren't highlighted.Suggested Improvements
Add a callout to the main documentation stating:
Update examples to either:
memoize/argsMemoizeoptions (since they're redundant)Current Versions Affected