I solved this problem by wrapping my press event with a class method that set the internal variable to true, then executed the original logic and set the internal variable to false again after its completion. You can then wrap the container component's event handler to see if the internal variable is set to true or false. eg:
<TouchableOpacity onPress={this.doSomething1}> <TouchableOpacity onPress={this.doSomething2}> <Image ... /> </TouchableOpacity> </TouchableOpacity> doSomething1() { this.preventDefault = true; doSomeLogic(); this.preventDefault = false; } doSomething2() { if(!this.preventDefault) { } }
Yossi
source share