I have a little Notification overlay component similar to this one
When it appears, the scroll of the page below is blocked, on both ios and Android.
What did I do wrong?
My Code :
const Notification: React.FC<NotificationProps> = (props) => {
let { message, componentId } = props;
const _translateY = useRef(new Animated.Value(_initTransY)).current;
useEffect(() => {
Animated.spring(
_translateY,
{
toValue: _endTransY
}
).start();
setTimeout(
()=>{
Animated.spring(
_translateY,
{
toValue: _initTransY
}
).start(
()=>{ Navigation.dismissOverlay(props.componentId); }
);
},
4000
);
}, []);
return (
<Animated.View style={[styles.root, { transform: [ { translateY: _translateY } ]}]}>
<View style={styles.notifWrap}>
<Text style={styles.notifText}>{message}</Text>
</View>
</Animated.View>
);
// <SafeAreaView style={styles.sav}>
// </SafeAreaView>
};
Notification.options = {
layout: {
componentBackgroundColor: 'transparent'
},
overlay: {
interceptTouchOutside: false
}
}
const styles = StyleSheet.create({
// sav: {
// position : 'absolute',
// height: 80,
// backgroundColor: 'red',
// },
root: {
width: '100%',
height: 80,
backgroundColor: 'red',
},
notifWrap: {
height: 60,
width: '100%',
elevation: 2,
backgroundColor: Colors.Bg07,
alignItems: 'center',
justifyContent: 'center',
},
notifText: {
fontFamily: Fonts.RobotoRegular,
color: Colors.Text04,
textAlign: 'center',
fontSize: 16,
}
});
export default Notification;
The way I show the overlay:
export const showNotification = (str:string)=>{
return Navigation.showOverlay({
component: {
name: Screens.Notification,
passProps: {
message: str
},
options: {
overlay: {
interceptTouchOutside: false,
},
layout: {
backgroundColor: 'transparent',
componentBackgroundColor: 'transparent',
orientation: ['portrait']
}
}
},
});
}
@guyca do you see something here?
If you registered screens with Gesture Handler its the problem
ah, you mean the gestureHandlerRootHOC from 'react-native-gesture-handler'?
Yes I did.
Isn't it something we should fix (maybe in 'react-native-gesture-handler')?
As a workaround, I could perhaps not wrap the overlay screen with gestureHandlerRootHOC as I actually do not use gestures there...
ok, I can confirm that not wrapping my Notification component in gestureHandlerRootHOC solves the problem. Thanks a lot @batuhansahan !
PS : @guyca that could be added as a note in the documentation as 'react-native-gesture-handler' is used a lot by the community...
SafeAreaProvider from react-native-safe-area-context causes the same problem.
@expo/react-native-action-sheet also causes this issue.
Most helpful comment
ok, I can confirm that not wrapping my Notification component in
gestureHandlerRootHOCsolves the problem. Thanks a lot @batuhansahan !