You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(b is actually a far deeper series of nested objects (including b.c and every other property in b, but for simplicity sake I've left that out it here)
I have the following selector
createSelector(state=>state.a,state=>state.b.c,(a,c)=>{/* some expensive computation here */})
a changes rarely and is suitable for the default strict equality check.
However b changes frequently (and the nature of the changes mean b.c fails the strict equality check), yet b.c itself rarely has a meaningful change. This causes the selector to be recomputed a lot needlessly.
So I attempted to use createSelectorCreator with a deep equal function, as per the documentation. My first attempt resulted in the following selector code:
constcreateDeepEqualSelector=createSelectorCreator(defaultMemoize,equal)constcSelector=createDeepEqualSelector(state=>state.b.c)createSelector(state=>state.a,cSelector,(a,c)=>{/* some expensive computation here */})
However this still called my main selector every time b was updated, even if b.c was unchanged.
Eventually I got it working by changing cSelector to be
Having looked at the code it appears as though the problem is the use of defualtMemoizehere rather than the user provided memoize and memoizeOptions.
I might be wrong about this being the cause, as I haven't yet managed to understand fully how this library is functioning internally, but it seem intuitiviely suboptimal that I need to add a dummy function for this usecase to work.
The text was updated successfully, but these errors were encountered:
Here's my situation:
(
b
is actually a far deeper series of nested objects (includingb.c
and every other property inb
, but for simplicity sake I've left that out it here)I have the following selector
a
changes rarely and is suitable for the default strict equality check.However
b
changes frequently (and the nature of the changes meanb.c
fails the strict equality check), yetb.c
itself rarely has a meaningful change. This causes the selector to be recomputed a lot needlessly.So I attempted to use
createSelectorCreator
with a deep equal function, as per the documentation. My first attempt resulted in the following selector code:However this still called my main selector every time
b
was updated, even ifb.c
was unchanged.Eventually I got it working by changing
cSelector
to beHaving looked at the code it appears as though the problem is the use of
defualtMemoize
here rather than the user providedmemoize
andmemoizeOptions
.I might be wrong about this being the cause, as I haven't yet managed to understand fully how this library is functioning internally, but it seem intuitiviely suboptimal that I need to add a dummy function for this usecase to work.
The text was updated successfully, but these errors were encountered: