import React, { useState } from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
export default function SimpleButtonScreen() {
const [pressed, setPressed] = useState(false);
return (
<View style={styles.container}>
<Button title="Press me" onPress={() => setPressed(true)} />
<Text style={styles.text} accessibilityRole="text">
{pressed ? 'Button pressed!' : 'Not pressed yet'}
</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 16
},
text: {
marginTop: 20,
fontSize: 18
}
});This screen uses React Native's useState hook to track if the button was pressed.
The Button component triggers setPressed(true) on press, changing the text below it.
The Text component updates to show the current state.
For snapshot testing, you capture the initial render (before pressing) to ensure the UI stays consistent over time.