How to trigger onPress event of TouchableOpacity?

Viewed 3110

Using jQuery in html:

$("input:button").on("click",function(){alert(1)}).click()

It can trigger click event.

I want to do the similar thing to onPress event of TouchableOpacity in react-native.

<TouchableOpacity activeOpacity={0.75} key={id} onPress={() => {onChangeAttribute(key)}}>
    {<Text>{value.name}</Text>}
</TouchableOpacity>

I don't know how to do this. I google it but found nothing. I just want to trigger onPress event in code not by user's tapping.

Thanks in advance.

1 Answers
Related