From 2b7e7d89e0bb5c3027fc10e163cb54297096cac8 Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Thu, 27 Dec 2018 16:44:24 +0200 Subject: [PATCH] fix-next: undefined root view when reapplying styles (#6729) * fix: undefined root view when reapplying styles Error: ``` JS ERROR TypeError: undefined is not an object (evaluating 'application_1.getRootView()._onCssStateChange') ``` Steps: - `tns run --hmr` - make a change in application styles - restart the application --- tns-core-modules/application/application-common.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tns-core-modules/application/application-common.ts b/tns-core-modules/application/application-common.ts index 3f0d0888c..71af5ddc3 100644 --- a/tns-core-modules/application/application-common.ts +++ b/tns-core-modules/application/application-common.ts @@ -89,8 +89,9 @@ export function livesync(context?: HmrContext) { reapplyAppCss = extensions.some(ext => context.module === fileName.concat(ext)); } - if (reapplyAppCss) { - getRootView()._onCssStateChange(); + const rootView = getRootView(); + if (reapplyAppCss && rootView) { + rootView._onCssStateChange(); } else if (liveSyncCore) { liveSyncCore(); }