From the course: Building Modern Projects with React
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Using the createSelector function - React.js Tutorial
From the course: Building Modern Projects with React
Using the createSelector function
- [Instructor] All right, so at this point, we've seen how to create simple selectors as well as more complex selectors. But the fact is that the Redux toolkit actually provides us with a function that makes it so that more complex selectors like these ones work more efficiently, right? Because right now, every time one of these selectors needs to get a value from the store, it has to recompute the answer which, depending on how complex that logic is, might take a long time. However, and I'm just going to import this thing up here, if we use a function called 'createSelector,' which we're going to import from the Redux toolkit, this will actually add something known as 'memoization' to the selectors, right? The more complex selectors that we create. So here's how this is going to work. We're actually going to change how we're defining these things. I'm just going to move this down to the bottom there for now to get it out of the way. We are going to need that logic a little bit later.…