-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onPress events don't work with custom toast components #113
Comments
any updates here? We are facing the same issue :( |
onPress is not working for me with default component. |
Removing {...this.panResponder.panHandlers} fixed the onPress issue. |
For a quick & dirty fix, src/index.js can be changed like so. change the onMoveShouldSetPanResponder function to be something like this:
|
A few questions so we can pinpoint the issue:
Can you post a reproducible code sample? For example, this works fine on my side: const toastConfig = {
test: ({onPress}) => (
<TouchableOpacity
style={{height: 50, width: '100%', backgroundColor: 'pink'}}
onPress={onPress}
/>
),
};
const App = () => {
const showToast = () =>
Toast.show({
type: 'test',
onPress: () => console.log('pressed'),
});
return (
<SafeAreaView style={{flex: 1}}>
<Toast ref={(ref) => Toast.setRef(ref)} config={toastConfig} />
<TouchableOpacity onPress={showToast}>
<Text>Show toast</Text>
</TouchableOpacity>
</SafeAreaView>
);
}; (Also, removing pan responders is not a fix - would remove the swipe to dismiss) |
I've encountered same issue: no press event is being fired. I've tried it with code provided above. It seems to be platform specific. I've tested it on real device and emulators. On emulators with Android 11 and 9 it works correctly while there seems to be an issue on real device (Android 9 here). @JamesPerlman suggestion seems like a temporary fix. |
I have a
I then import that in
also regarding your last comment the pan responders don't need to be removed, but |
I have the latest version and I only tested on iOS. I have a bare RN project, no expo. |
For the time being, I'll add @JamesPerlman's solution as a quick patch. Thanks everyone for looking into it! |
published in |
this is still broken for me. the
did it change back? |
whether using
BaseToast
or my own component withTouchableOpacity
, theonPress
events are not firing. I think this is probably to do with the PanResponder in the root component. can anyone help?The text was updated successfully, but these errors were encountered: