From the course: React: Advanced Code Challenges
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
useReducer: Managing multiple states - React.js Tutorial
From the course: React: Advanced Code Challenges
useReducer: Managing multiple states
- [Instructor] All right, so what we're going to do is access now the state objects and then access the state, regarding the count and time from the state objects. Let's do the same also for the sidebar. Actually, we don't need to access anything from the sidebar, so let me actually remove this line, which is not necessary. Line 19. All right, so let's move straight to the items list. For the item list, we need to access the items, all right, to display the list. And from here, so let's refactor also, we want to actually access the message object, but also be able to dispatch actions from the main components, like this. So let's remove line 50 now. All right, so we can now dispatch the action, which is, so let's go back. We want to check out, so which are the name of the actions. So this is first set message and then add item. For the set message, you're going to need to pass one payload, you need to pass one object. So let's do that. It's going to be, instead of set message, it's…