I have a slice in my store I created with createEntityAdapter from Redux Toolkit. In Function components you can use useSelector with the selectors returned from adapter.getSelectors()
.
But how can I get all entities as an array (like with the selectAll selector) in a class based component? I am using connect with mapStateToProps, which just allows me to get either entities or ids as a prop, but not all entities as an array sorted in the same order as the ids are sorted...
Asked
Active
Viewed 1,432 times
3

Christoph Hummler
- 971
- 2
- 7
- 20
1 Answers
5
You would use the same selectAll
selector, but you would call it in your mapState
function for use with connect
instead of passing it to useSelector
:
const mapState = (state) => {
return {
items: itemsSelectors.selectAll(state)
}
}

markerikson
- 63,178
- 10
- 141
- 157