React-Native Pressable's don't respond when page visited again after back navigation
I have a Pressable a MyButton component which uses Pressable from react-native-gesture-handler:
import React from 'react';
import { StyleProp, ViewStyle } from 'react-native';
import { Pressable, PressableProps } from 'react-native-gesture-handler';
export type MyButtonProps = {
children?: React.ReactNode;
style?: StyleProp;
onPress: () => void;
} & PressableProps;
const MyButton = ({ children, onPress, style, ...props }: MyButtonProps) => {
return (
[
{
opacity: pressed ? 0.5 : 1,
},
style,
]}
onPress={() => {
console.log('onPress'); // logged only if page is visited for the 1st time
onPress();
}}
{...props}>
{children}
);
};
export default MyButton;
When visiting a page for the first time, all MyButtons (Pressables) work fine. But, when navigating back (either by using navigation.goBack() or by swipe), and then coming back to the screen - all MyButton components stop receiving onPress events.
Any idea why and how to workaround this?