Build: WelcomeScreen
This screen shows a simple welcome message centered on the screen.
Target UI
--------------------- | | | | | | | Welcome to the | | React Native | | App! | | | | | | | ---------------------
--------------------- | | | | | | | Welcome to the | | React Native | | App! | | | | | | | ---------------------
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function WelcomeScreen() { return ( <View style={styles.container}> {/* TODO: Add Text component here */} </View> ); } const styles = StyleSheet.create({ container: { flex: 1, // TODO: Add styles to center content }, });
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function WelcomeScreen() { return ( <View style={styles.container}> <Text style={styles.welcomeText}>Welcome to the React Native App!</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff' }, welcomeText: { fontSize: 24, fontWeight: 'bold', color: '#000' } });
We use a View as the main container and apply flex: 1 to fill the screen. The justifyContent: 'center' and alignItems: 'center' styles center the content vertically and horizontally, just like placing a picture in the middle of a frame. The Text component displays the welcome message with a larger font size and bold weight to make it stand out.
This simple layout is a great first step to understand how React Native arranges components on the screen.
--------------------- | | | | | | | Welcome to the | | React Native | | App! | | | | | | | ---------------------
View component in a React Native app?ViewView component is like a box that holds other components and helps arrange them on the screen.Text displays text, but View is for layout and grouping.View = container [OK]View with TextView handles user inputView fetches dataimport React from 'react'; is correct.View and Text are named exports from 'react-native', so import { View, Text } from 'react-native'; is correct.import React from 'react';
import { View, Text } from 'react-native';
export default function App() {
return (
Hello, React Native!
);
}App function returns a View containing a Text component with the string 'Hello, React Native!'.Text component on the screen inside the View.import React from 'react';
import { View, Text } from 'react-native';
export default function App() {
return (
Hello World
)
}View does not require a style prop to work. Semicolons are optional in JavaScript.View component to achieve this?flex: 1 and use justifyContent: 'center' for vertical centering and alignItems: 'center' for horizontal centering.Pass the test and this pattern moves unknown