import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
function Container(props) {
return (
<View style={styles.container}>
{props.children}
</View>
);
}
export default function WelcomeScreen() {
return (
<View style={styles.screen}>
<Container>
<Text style={styles.title}>Welcome Screen</Text>
<Text style={styles.message}>Hello, friend!{"\n"}This is your app.</Text>
</Container>
</View>
);
}
const styles = StyleSheet.create({
screen: {
flex: 1,
backgroundColor: '#fff',
justifyContent: 'center',
alignItems: 'center'
},
container: {
padding: 20,
alignItems: 'center'
},
title: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 10
},
message: {
fontSize: 16,
textAlign: 'center'
}
});We created a Container component that wraps its children inside a styled View. This lets us reuse the padding and center alignment style easily.
In WelcomeScreen, we use Container and pass two Text components as children. The first is the title with bigger, bold font. The second is the message with normal font size and centered text.
This shows how the children prop lets components wrap and display any nested content, making UI flexible and reusable.