课程: Hands-On Introduction: React
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Refactoring data
- [Narrator] So right now, if we wanted to do anything with the information about the cast members, it only exists inside the ListCast component. So here is where I'm actually loading the information from my data file, which is this cas.json file that has all the cast members in it. And what I need to do is, because I may want to use the information for the cast members in other places, I need to move that into the main app.js file. So I'm going to take this async function and useEffect from here, and that means that I'm not going to need this useEffect here. All right? And then I'm going to bring that into the app.js. I'll put it before this return statement. (keys tapping) And sometimes I like to leave a little bit of breathing room. I think this looks nicer. And let's go ahead and make this bigger just so we can see things better. Also, if I save, it's going to start showing errors until I fix everything…