calintamas / react-native-toast-message

Animated toast message component for React Native
MIT License
1.73k stars 265 forks source link

Option to Hide Toast on Navigate #543

Closed Keenan-Softserve closed 3 months ago

Keenan-Softserve commented 7 months ago

Is your feature request related to a problem? Please describe. I want to be able to decide when a toast should persist when navigating to a new screen (using react-navigation).

Describe the solution you'd like When displaying a toast Toast.show() one of the ToastShowParams (ToastOptions) should have a 'persist:boolean' that determines if the Toast should persist when the screen changes or not.

Additional context

Steven-MKN commented 3 months ago

Sounds like you need to hook into your own navigation actions and run Toast.hide(); when you want to dismiss it. Check (this)[https://reactnavigation.org/docs/navigation-events/#screenlisteners-prop-on-the-navigator] if you're using react native navigation.

Because as I think about it, the toast would have no way of knowing what navigation library you are using and how it should behave, but you have that information and the toast allows you to dismiss it when you want to.

Keenan-Softserve commented 3 months ago

Sounds like you need to hook into your own navigation actions and run Toast.hide(); when you want to dismiss it. Check (this)[https://reactnavigation.org/docs/navigation-events/#screenlisteners-prop-on-the-navigator] if you're using react native navigation.

Because as I think about it, the toast would have no way of knowing what navigation library you are using and how it should behave, but you have that information and the toast allows you to dismiss it when you want to.

Thank You for the the advice :), that helps.

It makes sense what you're saying that the toast wouldn't know which library you're using. I don't have enough experience yet so I just mentioned what would be ideal and thought there might be a way to do it. Maybe it could be an 'extra' in the docs, showing how to do something like this with the different libraries.