Nativebase: Controlled hiding of Toasts

Created on 9 Oct 2017  路  11Comments  路  Source: GeekyAnts/NativeBase

Hi guys! I want to hide all Toasts by my action or other event.
For example:

const toastId = Toast.show(config);
Toast.hide(toastId)

// or

Toast.hideAll();

Is it possible?

invalid

Most helpful comment

Added with 2.7.2

All 11 comments

@LonelyGriffin currently NativeBase does not support this. Will raise a feature request.

This kinda thing would be useful. FWIW the "hide all" should be as simple as adding the following code to ToastContainer:

static hide() {
    this.toastInstance._root.cloaseToast();
}

However, the larger idea of being able to have multiple toasts (and being able to refer to each) is something I'm interested in in general.

(Just seen your PR adding the hide method done exactly the way I describe. D'oh.)

@alexrussell @LonelyGriffin Could you please share the PR link

Found it

1304

@LonelyGriffin Having multiple Toast popping up for a single screen, this is something inappropriate as per design guidelines / use-case
Hence rejecting your request and PR same

@SupriyaKalghatgi having multiple toasts simultaneously _might_ not be best UX. However, I don't see why can't we still enable hiding the single toast using hide() method?

Implementation provided by @LonelyGriffin is quite appropriate and in fact, it cleans NB Toast implementation a bit.

I'd suggest giving this PR another chance since it was closed abruptly.

Added with 2.7.2

This function should be added to the documentation. And specified how it's intended to work. Because it doesn't work as expected for me.

I also don't see tests for hiding a Toast or, for example, showing one, hiding, showing a 2nd; which is what I'm trying to do.

hide(), show() have been added to config table of Toast in latest docs versions...

Was this page helpful?
0 / 5 - 0 ratings