Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/runtimeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { View } from '@nativescript/core';
import {
App,
Component,
ComponentPublicInstance,
RendererElement,
RendererNode,
VNode,
Expand All @@ -25,6 +26,7 @@ export const createNativeView = <T = View>(
contextOverrides?: { reload?(): void },
) => {
let isMounted = false;
let vm: ComponentPublicInstance | null;
const newApp = renderer.createApp(component, props);
// Destructure so as not to copy over the root app instance
const { app, ...rootContext } = rootApp._context;
Expand All @@ -35,7 +37,7 @@ export const createNativeView = <T = View>(
return {
context,
get vnode() {
return newApp._instance?.vnode;
return vm?.$.vnode;
},
get nativeView(): T {
return this.vnode?.el.nativeView;
Expand All @@ -49,7 +51,7 @@ export const createNativeView = <T = View>(
newApp._context[key] = context[key];
});

newApp.mount(root);
vm = newApp.mount(root);

isMounted = true;

Expand All @@ -58,6 +60,7 @@ export const createNativeView = <T = View>(
unmount() {
if (!isMounted) return;

vm = null;
newApp.unmount();

isMounted = false;
Expand Down