I use reselect to get parts of my redux state. i have a list of objects in my state. One of my subselector for my create selector is a filter function of this list:
state => state.list.filter(filterFunction)
So i pass this to my createSelector:
createSelector(
state => state.list.filter(filterFunction),
(subsetOfObjects) => subsetOfObjects.map(doSomething)
);
This filter function returns a subset of my objects in the list. So if the list changes, reselect always returns a new object, even if the subset didn't changed, because the list isn't the same (fully correct).
is there a possibility to get only a new object if there are changes to the objects or the filtered list?
filter
(your input selector) always returns a new object. AFAIK,reselect
compares the result of input selectors through===
(state.list.filter(filterFunction) === state.list.filter(filterFunction)
) and it will always befalse
even if the list doesn't change. – PadaukcreateSelector
ends up being useless. It will recompute on every call even if the state doesn't change, because the input selector (filter) always returns a new object. – Padauk