/** https://reactnative.dev/docs/touchableopacity */ import React, { Component } from "react"; import { StyleSheet, Text, TouchableOpacity, View } from "react-native"; class App extends Component { constructor(props) { super(props); this.state = { count: 0 }; } onPress = () => { this.setState({ count: this.state.count + 1 }); }; render() { const { count } = this.state; return ( <View style={styles.container}> <View style={styles.countContainer}> <Text>Count: {count}</Text> </View> <TouchableOpacity style={styles.button} onPress={this.onPress} > <Text>Press Here</Text> </TouchableOpacity> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", paddingHorizontal: 10 }, button: { alignItems: "center", backgroundColor: "#DDDDDD", padding: 10 }, countContainer: { alignItems: "center", padding: 10 } }); export default App;