import React, { useState } from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
export default function App() {
const [greeting, setGreeting] = useState('Welcome to Expo!');
const changeGreeting = () => {
setGreeting('Hello from Expo Go!');
};
return (
<View style={styles.container}>
<Text style={styles.greetingText}>{greeting}</Text>
<Button title="Change Greeting" onPress={changeGreeting} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff'
},
greetingText: {
fontSize: 24,
marginBottom: 20
}
});This app uses React Native with Expo Go to quickly create a simple welcome screen.
We use the useState hook to keep track of the greeting text. Initially, it shows 'Welcome to Expo!'.
The Text component displays the greeting, and the Button below it changes the greeting to 'Hello from Expo Go!' when pressed.
The View container uses flexbox to center the content both vertically and horizontally for a clean look.