From the course: React.js: Building an Interface
Unlock the full course today
Join today to access over 24,600 courses taught by industry experts.
Programming the sorting interface - React.js Tutorial
From the course: React.js: Building an Interface
Programming the sorting interface
- Let's work on building the toggle for this search functionality. So to do that, we're going to start in App.js, and what we need to do here is make sure that we pass along into the search component some of the information about the order and the sorting. So I'll pass along orderBy, as well as an onOrderBy event. I'll call it onOrderByChange, and this is going to be mySort, so it's going to receive a value called mySort from the dropdown, and then I'm going to setOrderBy using that variable. Then we'll set up the sortBy, pass that along, and create a method for that as well. All right, let's go ahead and save that. And now we'll need to go into our search component. I'll make sure that we received that into the main search component here under dropdown. So in order to get to this dropdown though, we'll need to pass that along here. So we'll add sortBy, onSortByChange, orderBy, and onOrderByChange. Now we can add…