From the course: Building Modern Projects with React

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating selectors

Creating selectors

From the course: Building Modern Projects with React

Start my 1-month free trial

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…

Contents