Let's say I have a selector like this:
const selectItemByGuid = (state, guid) => {
return state.items.find(i => i.guid == guid)
}
Now, I want to apply that selector to each guid in a list of guids.
export const selectSpecialItems = createSelector(
[selectSpecialEntityGuids],
guids => {
const items = guids.map(guid => selectItemByGuid(state, guid)) // Where do I get state here?
return items || []
},
)
How would I pass in state
to the inner selector?
Let's say I have a selector like this:
const selectItemByGuid = (state, guid) => {
return state.items.find(i => i.guid == guid)
}
Now, I want to apply that selector to each guid in a list of guids.
export const selectSpecialItems = createSelector(
[selectSpecialEntityGuids],
guids => {
const items = guids.map(guid => selectItemByGuid(state, guid)) // Where do I get state here?
return items || []
},
)
How would I pass in state
to the inner selector?
1 Answer
Reset to default 0You can pass state
to your selectSpecialItems
function as such which can then pass it down as an argument:
export const selectSpecialItems = createSelector(
[selectSpecialEntityGuids, state => state],
(guids, state) => {
...