To ensure that the Button inside a View with pointerEvents: 'none' can still receive pointer events, you need to set the pointerEvents: 'auto' property on the Button itself. However, it looks like you've already done that in your code snippet. The layout should work as intended if everything is structured correctly.
This configuration generally works and the Button should receive pointer events while the parent View does not. But let's ensure everything is set correctly, and I'll offer a bit more structure and detail if needed:
Make sure you import necessary components correctly.
Ensure the Button is using pointerEvents: 'auto'.
If you are using styles from StyleSheet, define them properly.
Here’s a more structured and complete example:
jsx
import React from 'react';
import { View, StyleSheet } from 'react-native';
import { Button } from 'react-native-paper'; // Assuming you are using react-native-paper for the Button
const MyComponent = () => {
const confirmLocation = () => {
// Your confirm location logic
};
return (
<View style={styles.container}>
<Button
onPress={confirmLocation}
style={styles.button}
mode="contained"
>
Confirm
</Button>
</View>
);
};
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
pointerEvents: 'none',
justifyContent: 'flex-end',
},
button: {
pointerEvents: 'auto',
margin: 30,
},
});
export default MyComponent;
In this example:
The container style uses ...StyleSheet.absoluteFillObject which is a shorthand for setting all four corners to 0 (effectively the same as StyleSheet.absoluteFill). It also sets pointerEvents: 'none', so the View itself does not receive touch events.
The button style sets pointerEvents: 'auto' explicitly so that it can still receive touch events.
This setup should ensure that the Button inside the View receives pointer events as expected, even though its parent View does not. If the button still does not respond to press events, you might want to check for other overlapping views or parent components that might be interfering with touch events.