Nativebase: Close Toast?

Created on 21 Jul 2017  路  5Comments  路  Source: GeekyAnts/NativeBase

Is there any way to close a toast programmatically?

I'm displaying one as an "error message" but I want to programmatically close it when the user is about to close the screen.

Wrapping my screen with the Root component (instead of doing that globally) works, however it does cause an error if you close the screen without closing the toast, and the you navigate back to the same screen.

Most helpful comment

Wouldn't a static close method in ToastContainer be enough for this task?

static close() { this.toastInstance._root.closeToast(); }

EDIT:

I just found out that the following will also work:

Toast.toastInstance._root.closeToast();

All 5 comments

Wouldn't a static close method in ToastContainer be enough for this task?

static close() { this.toastInstance._root.closeToast(); }

EDIT:

I just found out that the following will also work:

Toast.toastInstance._root.closeToast();

hey @shivrajkumar , did you close the issue 'cause Toast.toastInstance is the "official" way to close a toast?

@shivrajkumar ?!!

@nicgutierrez There is no "official" way to close the toast programmatically. But if that works for you, feel free to use that.
Let me know if that serves your your purpose so that we can close this.

@sankhadeeproy007 thanks for your reply. Toast.toastInstance._root.closeToast(); indeed works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bundas picture Bundas  路  3Comments

omerdn1 picture omerdn1  路  3Comments

nschurmann picture nschurmann  路  3Comments

natashache picture natashache  路  3Comments

bsiddiqui picture bsiddiqui  路  3Comments