Skip to content

Commit

Permalink
fix: object assign approach for inner app context
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Sep 11, 2023
1 parent cd7d46c commit 3a6dc31
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/TresCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() : [])
Expand Down

0 comments on commit 3a6dc31

Please sign in to comment.