Safe to pass different input selectors from different slices? #590
-
I was wondering if it's safe to pass two input selectors in If it is actually safe, then would it be better to create the selector instance in one of those slices or in the component where it is being used? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sure, there's no problem there. In fact, that's part of the point of selectors in the first place - to encapsulate looking up date from different parts of the state. We typically recommend defining selectors in a slice file, but it's up to you - Redux doesn't care where the selector function actually lives. See https://redux.js.org/usage/deriving-data-selectors for more details. |
Beta Was this translation helpful? Give feedback.
Sure, there's no problem there. In fact, that's part of the point of selectors in the first place - to encapsulate looking up date from different parts of the state.
We typically recommend defining selectors in a slice file, but it's up to you - Redux doesn't care where the selector function actually lives.
See https://redux.js.org/usage/deriving-data-selectors for more details.