In a tutorial I follow, they have this piece of code that creates 2 selectors:
const selectCart = (state) => state.cart;
export const selectCartHidden = createSelector(
[selectCart],
(cart) => cart.hidden
);
...
export const selectCartItemsCount = createSelector(
[selectCartItems],
(cartItems) => cartItems.reduce((a, item) => a + item.quantity, 0)
);
According to reselect, you should use createSelector if you are computing a value from state, so the second selector makes sense to me, but how about the first one? It is simply extracting data without any calculation, so would it be better to just write: selectCartHidden = state => state.cart.hidden
, because it will return the same value if unrelated part of the state changes anyway, so there is no need to memoize it?