From the course: React in Action: From Setup to Deployment
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Refactoring data - React.js Tutorial
From the course: React in Action: From Setup to Deployment
Refactoring data
- [Instructor] I want to add some content to my navigation, including the list of characters right here as a dropdown, but the fetching for the cast data happens inside this list cast component. So I need to move all this up a level so that any of my sub-components will be able to access the information right here. To do that, we'll need to refactor some of the code, and we'll get started by going into ListCast. And then grabbing this main section, and we'll cut this out of here. Let's go ahead and make this window bigger. And I'm not going to need to have either useEffect or useState, since the data will be inserted into this component. But since we're going to be receiving the data, we'll have to add it right here. We can also get rid of this constant here, which will set the value because we're going to be passing it into this method. We can also get rid of this variable in here. We're going to be passing it into this component. And that's all we need to do with ListCast for right…