Skip to content

Commit a3efb3a

Browse files
author
farfromrefug
committed
fix(snackbar): android prevent error if view to attach it too is not loaded
1 parent 96f997e commit a3efb3a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/snackbar/snackbar.android.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ export class SnackBar extends SnackBarBase {
5858
}
5959
}
6060
const page = (attachView instanceof Page ? attachView : attachView.page) || attachView;
61-
let nView = page instanceof Page ? (page.nativeViewProtected as android.view.View).getParent() : attachView.nativeViewProtected;
61+
let nView = page instanceof Page ? (page.nativeViewProtected as android.view.View)?.getParent() : attachView.nativeViewProtected;
62+
if (!nView) {
63+
console.warn(`the snackbar parent ${page} is not loaded`);
64+
return;
65+
}
6266
let nCoordinatorLayout: androidx.coordinatorlayout.widget.CoordinatorLayout = (page as any).nCoordinatorLayout;
6367
if (!nCoordinatorLayout && !(nView instanceof androidx.coordinatorlayout.widget.CoordinatorLayout) && nView instanceof android.view.ViewGroup) {
6468
nCoordinatorLayout = new androidx.coordinatorlayout.widget.CoordinatorLayout(attachView._context);

0 commit comments

Comments
 (0)