I created two selectors
To get all networks -
export const getAllNetworks = createSelector(getState, state => state.networks);get devices for each network
createSelector(getAllNetworks, network => { const selectedNetwork = network.filter(net => net.id === networkId); return selectedNetwork[0]?.allDevices; });
I wanted to create a third selector which uses the first selector to get networks and then uses the second selector to get additional data
export const something = createSelector(
getAllNetworks, (networks) => {
networks.map(
// How can I call the selector selectNetworkDevices by passing the network ID here and get the devices [ex: selectNetworkDevices(network.id)]
)
}
)
You can use different selectors based on others like this:
In your component you could call this selector either providing the parameter or not:
More information here: link
UPDATE:
We have 2
selectors,selectAccountsandmyOtherSelector. FormyOtherSelector, instead of calling directly theselectAccountsselector, you can reuse its logic by calling its callback function.