|
When using a react native gesture handler Pressable, I would like to implement custom handlers using the PressableEvent, but I can't because it is not properly exported. Is there any specific reason for this? // ts error because PressableEvent is not exported
import { Pressable, PressableEvent} from 'react-native-gesture-handler'
const handlePress = (event: PressableEvent) => {
onPress(event)
} |
Answered by
m-bert
Jul 21, 2026
Replies: 1 comment 1 reply
|
Wondered the same thing today. |
1 reply
|
Until that type is exported, a nice workaround is to infer it from the component props instead of hardcoding it. Example: import type { ComponentProps } from 'react';
import { Pressable } from 'react-native-gesture-handler';
type GHPressEvent = Parameters<
NonNullable<ComponentProps<typeof Pressable>['onPress']>
>[0];
const handlePress = (event: GHPressEvent) => {
onPress(event);
};If you do not need the exact inferred type, |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't recall one, it was probably overlooked 😅 I've merged #4324, so it should be available after next release 😅