react-native-root-toast
react-native-root-toast copied to clipboard
Feature Request: Can We Introduce OnPress() For Custom Buttons On The Toast?
First off, thanks for the great project + maintenance.
The project has a hideOnPress() property, therefore user can interact with the toast. Can we expose the OnPress() so that we can add button(s) on the toast?
Usage would be:
User enters some invalid info, then toast would be:
you entered invalid info.
button: Reset
another button: Save Anyway
+1
+2
For anyone finding this, onPress is already exposed -- just not documented.
let toast = Toast.show("This is a message", { duration: Toast.durations.LONG, position: Toast.positions.TOP, shadow: true, animation: true, hideOnPress: true, delay: 0, onPress: () => { // calls on toast being pressed }, onShow: () => { // calls on toast\s appear animation start
},
onShown: () => {
// calls on toast`s appear animation end.
},
onHide: () => {
// calls on toast`s hide animation start.
},
onHidden: () => {
// calls on toast`s hide animation end.
}
});`
~~Yes, although the function receives no information from the toast so it's difficult to act on the keypress in any meaningful way.~~
Because this is set on the toast options for the particular notification, of course you can load in whatever action you want. I think this can be closed.
CC: https://github.com/magicismight/react-native-root-toast/pull/10