Skip to content

fix: reference returned instance #1068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2023
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
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