”’
import { StyleSheet, Text, View, SafeAreaView, TouchableOpacity, Button } from ‘react-native’
import React from ‘react’
const onPressHndler = () => {
<View>
<Text>
Hello world
</Text>
</View>
}
export default () =>{
return(
<SafeAreaView>
<View>
<Button title='press' onPress={onPressHndler}/>
</View>
</SafeAreaView>
)
}
2
Answers
your function must define the action you expect your code to do not the outcome you expect to see, while the condition in your JSX will make sure that the content follows this logic.
You can even alter the same state false/true
Now a press on the button will show content, another will hide it.