React-native: pointerEvents={'none'} does not work on Android

Created on 14 Jul 2019  ·  2Comments  ·  Source: facebook/react-native

Bug

I try to use pointerEvents={'none'} on Image component, but it does not work on Android. It is effective on iOS.

React Native version:

 React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
      Memory: 141.91 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 12.1.0 - /usr/local/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 24, 26, 27, 28
        Build Tools: 26.0.2, 27.0.3, 28.0.2, 28.0.3
        System Images: android-24 | Google APIs Intel x86 Atom, android-27 | Intel x86 Atom_64, android-28 | Intel x86 Atom_64
    IDEs:
      Android Studio: 3.0 AI-171.4443003
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.9 => 0.59.9 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Steps To Reproduce

export default class GeneralBackground extends PureComponent {

    render() {
        return (
            <View style={styles.container}>
                {this.props.children}
                <Image
                    source={myImage}
                    style={styles.image}
                    pointerEvents={'none'} // Does not work on Android.
                />
            </View>
        );
    }

}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: Colors.theme
    },
    image: {
        width: 160,
        resizeMode: 'stretch',
        alignSelf: 'center',
        position: 'absolute'
    }
});

I expect that this.props.children like Button component can be work but not Image above. But it can work on iOS via testing, Android failed. Did I use it by mistake? I think it maybe a bug.
Anybody knows that? Thanks a lot in advance.

Bug Android

Most helpful comment

Hi @Amos729,

It seems that the pointerEvents prop is not available on the Image component: searching pointerEvents on https://facebook.github.io/react-native/docs/image yielded nothing.

I believe it's only available for View components: https://facebook.github.io/react-native/docs/view#pointerevents

Doing something like that

<View style={styles2.image} pointerEvents={'none'}> 
   <Image source={myImage} />
</View>

made a children Button clickable on Android.

Hope that helps!

All 2 comments

Hi @Amos729,

It seems that the pointerEvents prop is not available on the Image component: searching pointerEvents on https://facebook.github.io/react-native/docs/image yielded nothing.

I believe it's only available for View components: https://facebook.github.io/react-native/docs/view#pointerevents

Doing something like that

<View style={styles2.image} pointerEvents={'none'}> 
   <Image source={myImage} />
</View>

made a children Button clickable on Android.

Hope that helps!

@RobinCsl I tried what you said just now. It's really useful both Android and iOS platform.
Thank you so much.

Was this page helpful?
0 / 5 - 0 ratings