I have the following component in React Native:
<View style={{ flex: 1, width: "100%", backgroundColor: "white" }} >
<View style={{ position: "absolute", top: 20, left: 20, height: 100, width: 100, backgroundColor: 'red' }}>
<TouchableWithoutFeedback onPress={() => console.log("clicked")}>
<View style={{ position: "absolute", top: 20, left: 20, height: 200, width: 200, backgroundColor: 'blue'}}>
</View>
</TouchableWithoutFeedback>
</View>
</View>
This renders the following screen:
Now when I click on the part of the child (blue) component that is outside of the parent (red) component it doesn’t log “click” on Android. But when I run this app on iOS, it does log “click” when clicked outside of the parent on the child component.
What is the reason that it does work on iOS but not on Android? Should I use a different component specifically for Android?
Thanks in advance.
Version information:
Output of react-native info:
System:
OS: macOS 12.0.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 157.67 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.10.0 - /var/folders/0k/l1gbyzj91lzg98pqcyp95xl40000gn/T/yarn--1653119182599-0.2342745454309867/node
Yarn: 1.22.18 - /var/folders/0k/l1gbyzj91lzg98pqcyp95xl40000gn/T/yarn--1653119182599-0.2342745454309867/yarn
npm: 7.24.0 - ~/.nvm/versions/node/v16.10.0/bin/npm
Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7784292
Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
Languages:
Java: 15.0.2 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.3 => 0.64.3
react-native-macos: Not Found
