I have the following selectors setup
selectors.js
const getNodeHistory = (state) => state.session.nodeHistory;
const getUnit = (state, unit) => unit;
export const selectNodeHistory = createSelector(
[getNodeHistory, getUnit],
(history, unit) => history.filter((h) => h.unit === unit)
);
Component
const nodeHistory = useSelector((state) => selectNodeHistory(state, unit));
However each component that uses selectNodeHistory re-renders any time there is a change to state.session.nodeHistory i.e a new item added or changed, even if that item doesn't belong to the filtered selector.
Not sure if I'm doing something wrong or it's not possible using this method.