Skip to content

Commit fd5236f

Browse files
committed
fix: undefined right-hand side of instance of
fixes #8739
1 parent a148cf4 commit fd5236f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/core/ui/layouts/flexbox-layout/index.android.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ export * from './flexbox-layout-common';
77
let widgetFlexboxLayout: typeof org.nativescript.widgets.FlexboxLayout;
88
let widgetLayoutParams: typeof org.nativescript.widgets.FlexboxLayout.LayoutParams;
99

10+
function ensureNativeTypes() {
11+
if (!widgetFlexboxLayout) {
12+
widgetFlexboxLayout = org.nativescript.widgets.FlexboxLayout;
13+
widgetLayoutParams = widgetFlexboxLayout.LayoutParams;
14+
}
15+
}
16+
1017
function makeNativeSetter<T>(setter: (lp: org.nativescript.widgets.FlexboxLayout.LayoutParams, value: T) => void) {
1118
return function (this: View, value: T) {
19+
ensureNativeTypes();
1220
const nativeView: android.view.View = this.nativeViewProtected;
1321
const lp = nativeView.getLayoutParams() || new widgetLayoutParams();
1422
if (lp instanceof widgetLayoutParams) {
@@ -76,10 +84,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
7684

7785
constructor() {
7886
super();
79-
if (!widgetFlexboxLayout) {
80-
widgetFlexboxLayout = org.nativescript.widgets.FlexboxLayout;
81-
widgetLayoutParams = widgetFlexboxLayout.LayoutParams;
82-
}
87+
ensureNativeTypes();
8388
}
8489

8590
public createNativeView() {

0 commit comments

Comments
 (0)