From 3a6dc317c39cba6b2ebcdcf372eb8ccd6676ef2e Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Mon, 11 Sep 2023 19:07:58 +0200 Subject: [PATCH] fix: object assign approach for inner app context --- src/components/TresCanvas.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/TresCanvas.vue b/src/components/TresCanvas.vue index 9dcbd0f46..ad958785c 100644 --- a/src/components/TresCanvas.vue +++ b/src/components/TresCanvas.vue @@ -83,13 +83,22 @@ const slots = defineSlots<{ default(): any }>() -const vueApp = getCurrentInstance()?.appContext.app +const instance = getCurrentInstance()! const createInternalComponent = (context: TresContext) => defineComponent({ setup() { - const ctx = getCurrentInstance()?.appContext - if (ctx) ctx.app = vueApp as App + const inner = getCurrentInstance()! + + Object.assign(inner.appContext, instance.appContext) + //@ts-expect-error: internal property + Object.assign(inner.provides, inner.appContext.provides) + if (import.meta.env.DEV) { + //@ts-expect-error: internal property + inner.appContext.reload = () => { + mountCustomRenderer(context) + } + } provide('useTres', context) provide('extend', extend) return () => h(Fragment, null, slots?.default ? slots.default() : [])