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.
Combining selectors - React.js Tutorial
From the course: Building Modern Projects with React
Combining selectors
- [Instructor] Alright, so now that we've created simple selectors for getting the todos and getting whether or not the todos are loading, let's see how we can create some somewhat more complex selectors that will be useful to our application. In particular, it would be great if we could go back to having separate lists for completed and incomplete todos and that's something that selectors can really help us out with. So here's what this is going to look like. We're going to go back into our selectors file and what we're going to do, I'm just going to keep sort of a visual separation between what I'm going to refer to as atomic selectors, right? Selectors that refer directly to the state, and selectors that modify the return value of an atomic selector in some way. That might sound a little bit confusing, so let me just show you what I mean here. What if we define a new selector here called something like getCompletedTodos, and this selector, what it could do is actually use the…