import React, { useState } from "react"; import { StyleSheet, TouchableOpacity, Text, View } from "react-native"; const TouchableOpacityExample = () => { const [count, setCount] = useState(0); const [count1, setCount1] = useState(0); return ( <View style={styles.container}> <View style={styles.countContainer}> <Text>Default TouchableOpacity - 0.2</Text> <Text style={styles.countText}>Count: {count}</Text> </View> <TouchableOpacity onPress={() => setCount(count + 1)} > <View style={styles.button}> <Text style={{color: '#FFFFFF'}}>Touch Here</Text> </View> </TouchableOpacity> <View style={[styles.countContainer, {marginTop: 40}]}> <Text>activeOpacity=0.6</Text> <Text style={styles.countText}>Count: {count1}</Text> </View> <TouchableOpacity onPress={() => setCount1(count1 + 1)} activeOpacity={0.6} > <View style={styles.button}> <Text style={{color: '#FFFFFF'}}>Opacity - 0.6</Text> </View> </TouchableOpacity> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", paddingHorizontal: 10 }, button: { alignItems: "center", backgroundColor: "#FF0000", padding: 10, }, countContainer: { alignItems: "center", padding: 10 }, countText: { color: "#FF00FF" } }); export default TouchableOpacityExample;