-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Parametrised selectors memoization #999
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
Comments
Hm, that is actually a real problem. createDraftSafeSelector(
selectGlobalizedEntities,
selectId,
selectById
) and while Coincidentally, that should already get solved by accident in #990 - can you take a look and verify that? |
It's important to realize that for |
@markerikson not 100% agreeing. Assuming you have 100 components and many entities, I would not want |
const selectGlobalizedEntities = createDraftSafeSelector(
selectState,
selectEntities
) It's only going to re-run the output selector once the entities state changes, and even then it's a straight lookup: |
Ah right, it's prefaced with |
It seems that none of 5 memoized selector actually benefit from |
In general: it doesn't hurt having it in there. |
But it does hurt very very slightly for selectors like |
We're talking a couple comparisons and a Realistically, |
Uh oh!
There was an error while loading. Please reload this page.
Hello, according to docs and source code, all selectors are created with
createSelector
fromreselect
.reselect
does not provide a way to handle parametrised selectors and recommends taking approach like suchAnd then in
react-redux
version we would create selector instance for each component that needs itWhen using
redux-toolkit
and creating globalized selectors like thisglobalizedSelectors
becomes this single instance and if I were to use it like thisSelector memoization would become pointless, as each component will pass different
id
and overwrite cached version.I could however do something like this
And have instances created each time. But then in my opinion it would be efficient to access non-memoized selectors from
redux-toolkit
and use them like thisThe text was updated successfully, but these errors were encountered: