1

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.

2

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Wrap View in TouchableOpacity

<TouchableOpacity onPress={handler}> <View style={{ flexDirection: 'row', }} > <Text>Hello World!<Text /> <View /> </TouchableOpacity> 

Comments

1
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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.