Skip to content

Commit 3948da5

Browse files
authored
fix: reference returned instance (#1068)
1 parent d8c1592 commit 3948da5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/runtimeHelpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { View } from '@nativescript/core';
22
import {
33
App,
44
Component,
5+
ComponentPublicInstance,
56
RendererElement,
67
RendererNode,
78
VNode,
@@ -25,6 +26,7 @@ export const createNativeView = <T = View>(
2526
contextOverrides?: { reload?(): void },
2627
) => {
2728
let isMounted = false;
29+
let vm: ComponentPublicInstance | null;
2830
const newApp = renderer.createApp(component, props);
2931
// Destructure so as not to copy over the root app instance
3032
const { app, ...rootContext } = rootApp._context;
@@ -35,7 +37,7 @@ export const createNativeView = <T = View>(
3537
return {
3638
context,
3739
get vnode() {
38-
return newApp._instance?.vnode;
40+
return vm?.$.vnode;
3941
},
4042
get nativeView(): T {
4143
return this.vnode?.el.nativeView;
@@ -49,7 +51,7 @@ export const createNativeView = <T = View>(
4951
newApp._context[key] = context[key];
5052
});
5153

52-
newApp.mount(root);
54+
vm = newApp.mount(root);
5355

5456
isMounted = true;
5557

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

63+
vm = null;
6164
newApp.unmount();
6265

6366
isMounted = false;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy