- The newline Guide to Fullstack ASP.NET Core and React
- State management with Redux
Using Selectors in Entity Adapters
In this lesson, we're going to use selectors provided by Entity Adapters
Now you know how createEntityAdapter normalizes the data and how it's getting stored inside Redux. We have seen a few methods like setOne, setMany, upsertOne etc. It also gives us selectors to extract data from. Inside, it has methods like selectById, selectByIds, selectAll, selectEntities and selectTotal. It's an efficient way to query a big chunk of data.
Let's implement it in our code to take advantage of it. Inside courseSlice, let's export a new const called courseSelector which will be equal to the coursesAdapter.getSelectors. Inside, we need state which will get state.course; let's give type RootState to our state. Now we will use the courseSelectors to use the selector methods provided by redux toolkit.
client/src/redux/slice/courseSlice.ts
This page is a preview of The newline Guide to Fullstack ASP.NET Core and React