From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

useSelector problems

useSelector problems

Welcome to lesson number 8 of this course. In this lesson, we are going to learn about the advanced Redux selectors with reselect library. So let's recap why we need selectors. Selectors are functions that extract the data from the store. It gives us the initial state of that data that we need and we can do that by using use selector hook. By having selectors, we keep the component decoupled from the state's shape. So our code does not have idea that how the state is being shaped and the component doesn't have to worry about that. It can just use the use selector hook and it gets the initial state of the value. And then you have declared an interface for that. So you get IntelliSense and you can simply shape your component according to that. This improves readability and reusability. So all the other components just has to get the initial state of your slice by using the use selector hook, and they don't have to worry about declaring the objects every time in the component. But there…

Contents