From bd4184e78bffe3d9e7fe6b4f339d63e31a7ddb91 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 4 Sep 2020 08:12:50 -0700 Subject: [PATCH] fix(android): undefined right-hand side of instance of Picked from master: https://github.com/NativeScript/NativeScript/commit/fd5236f1b376d12a7749d4fb7929584b8cf6a47c --- .../flexbox-layout/flexbox-layout.android.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.android.ts b/nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.android.ts index 8f64adb54..01b761d15 100644 --- a/nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.android.ts +++ b/nativescript-core/ui/layouts/flexbox-layout/flexbox-layout.android.ts @@ -17,8 +17,16 @@ export * from "./flexbox-layout-common"; let widgetFlexboxLayout: typeof org.nativescript.widgets.FlexboxLayout; let widgetLayoutParams: typeof org.nativescript.widgets.FlexboxLayout.LayoutParams; +function ensureNativeTypes() { + if (!widgetFlexboxLayout) { + widgetFlexboxLayout = org.nativescript.widgets.FlexboxLayout; + widgetLayoutParams = widgetFlexboxLayout.LayoutParams; + } +} + function makeNativeSetter(setter: (lp: org.nativescript.widgets.FlexboxLayout.LayoutParams, value: T) => void) { return function (this: View, value: T) { + ensureNativeTypes(); const nativeView: android.view.View = this.nativeViewProtected; const lp = nativeView.getLayoutParams() || new widgetLayoutParams(); if (lp instanceof widgetLayoutParams) { @@ -86,10 +94,7 @@ export class FlexboxLayout extends FlexboxLayoutBase { constructor() { super(); - if (!widgetFlexboxLayout) { - widgetFlexboxLayout = org.nativescript.widgets.FlexboxLayout; - widgetLayoutParams = widgetFlexboxLayout.LayoutParams; - } + ensureNativeTypes(); } public createNativeView() {