In this lab, you will learn how to create REACT Native apps using the full spectrum of UI components available. You will also learn how to use styling and layout to create visually appealing and responsive apps.
Prerequisites
Before beginning this lab, you should have a basic understanding of JavaScript and familiarity with REACT Native. You should also have the following software installed:
Node.js
REACT Native CLI
A code editor (Visual Studio Code is recommended)
Getting Started
To begin, create a new REACT Native project using the following command:
npx react-native init MyApp
Replace MyApp with the name of your project. Navigate to the project directory and start the development server using the following command:
d MyApp
npx react-native start
In a separate terminal window, run your app using the following command:
npx react-native run-ios # for iOS
npx react-native run-android # for Android
Your app should now be running on your device or emulator.
Creating UI Components
REACT Native provides a wide range of UI components that you can use to create your app's interface. In this section, you will learn how to create some of the most commonly used components.
Text
The Text component is used to display text on the screen. You can use it like this:
importReactfrom 'react';
import { Text } from 'react-native';
constApp = () => {
return (
<Text>Hello, world!</Text>
);
};
exportdefaultApp;
View
The View component is used to create a container that can hold other components. You can use it like this:
importReactfrom 'react';
import{ View, Text } from 'react-native';
constApp = () => {
return (
<View>
<Text>Hello, world!</Text>
</View>
);
};
exportdefaultApp;
Image
The Image component is used to display images on the screen. You can use it like this:
You can layout components using the flex property. The flex property takes a number that determines how much space the component should take up relative to its siblings. For example:
This will create a row with three boxes, where the first box takes up 1/6 of the available space, the second box takes up 2/6, and the third box takes up 3/6.
Conclusion
In this lab, you learned how to create REACT Native apps using the full spectrum of UI components available. You also learned how to use styling and layout to create visually appealing and responsive apps. With these skills, you can create apps for both iOS and Android devices. Good luck!
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (