Repository navigation
Replies: 1 comment
|
Make the chosen list an input to the selector, and do the filtering in the result function: import { createSelector } from 'reselect';
const selector2 = state => state.a.b.key;
const selector3 = state => state.c.d.type;
const selectList = state =>
selector3(state) === 1 ? state.list1 : state.list2;
const selector4 = createSelector(
[selectList, selector2],
(list, key) => list.filter(entry => entry.key === key)
);Call This preserves your I checked this with Reselect 4.1.8 and 5.3.0: unrelated state changes reused the result array; replacing the selected list, changing the key, or switching lists recalculated it. This follows the documented pattern of simple input selectors with calculations in the result function. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I was wondering what's the best practice to handle the following case
Many thanks.
All reactions