import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
export default function GreetingScreen() {
const name = 'Friend';
return (
<View style={styles.container}>
<Text style={styles.greeting}>Hello, {name}!</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
greeting: {
fontSize: 24,
fontWeight: 'bold',
},
});We created a Text component inside the View. Inside the Text, we used curly braces {} to insert the variable name dynamically. This is called interpolation in React Native. It lets us show the value of variables inside text easily. The name is set to 'Friend' initially, so the screen shows 'Hello, Friend!'.