Assume we have a selector written with createSelector
const getSmth = createSelector(
getState,
state => state.items || {}
)
Does memoization still works or it will recalculate each time cause we return a new reference? As far as I know, reselect does equality check by reference ===? Or reselect store this to a variable and the reference will be the same?
getSmthis a generated selector.getStateis the input selector,state => state.items || {}is the output selectorIf the generated selector is called multiple times, the "output" selector will only be recalculated when the extracted values have changed.
The calculated result(derived data) has nothing to do with the recalculation. This means the output selector returns the same reference or a new reference does not matter.
E.g.
Output: