From the course: Building Modern Projects with React
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Creating selectors
From the course: Building Modern Projects with React
Creating selectors
- [Instructor] So now we know the basics of why we need selectors in a React Redux application and the basics of what a selector is. In this video we're going to create our first selectors and incorporate them into our application. You saw previously that selectors are meant to abstract away how data is stored in redux as well as give us a place to put logic for transforming redux data into data that our components can use. We're going to start off by looking at the first purpose, abstracting away how our data is stored in Redux. If we open up our to-do list component, we can see that in the mapStateToProps function we're referring directly to how our data is stored. What we're going to do is take these two things: state.todos and state.isLoading and create selectors for them. So inside our todos directory let's create a new file called selectors.js and then inside this file we're going to create a function called…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.