Reputation: 6624
What is the equivalent for linearLayout.setClickable(true);
(Android) in React Native below :
<View style={{ flexDirection: 'row', }} ><Text>Hello World!<Text /><View />
I would like to make the <View />
container / wrapper clickable.
Thank you all.
Upvotes: 1
Views: 1035
Reputation: 10719
Just wrap your container in a Touchable.
For example:
<TouchableOpacity onPress={() => console.log('onPress')}>
<View style={{ flexDirection: 'row', }} >
<Text>Hello World! </Text>
</View>
</TouchableOpacity>
Btw. In your example the closing tags were wrong, I corrected them in my example.
Upvotes: 1
Reputation: 376
import { Text, View, TouchableOpacity } from "react-native";
<TouchableOpacity onPress={() => pressHandler()}>
<View style={{ flexDirection: 'row', }} ><Text>Hello World!<Text /><View />
</TouchableOpacity>
);
wrap those inside TouchableOpacity or any other Touch wrappers
Upvotes: 1
Reputation: 1390
Wrap View in TouchableOpacity
<TouchableOpacity onPress={handler}>
<View style={{ flexDirection: 'row', }} >
<Text>Hello World!<Text />
<View />
</TouchableOpacity>
Upvotes: 1