From the course: Learning React Native
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Importing a custom component
- [Instructor] It's absolutely fine to work with components in the same file. However, once you've finished a component, it's usually a good idea to move that code base to its own file. Let's do that with the Color Button. I'm going to go ahead and copy the entire Color Button function and I'll come over here to my Source files. I'm going to click this little plus folder icon to add a new folder. I'm going to call that folder, Components, and then within the Components confolder, I'm going to create a new ColorButton.js file. This is where we'll put the Color Button. So I can collapse the current file folder and we'll paste our Color Button directly into this file. Now that the Color Button's off on its own in a file, we need to make sure that we export it. So I'll type export default in front of my Color Button function. Our Color Button has some dependencies, so I'm going to go to the App.js file and just copy all of…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.