Skip to content

Commit

Permalink
fix: 🐛 redo imports and manage tick
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeloSchulerPiletti committed Nov 15, 2023
1 parent 8a56466 commit f2c88d9
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/runtime/components/ExcalidrawBoard.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue'
import React from 'react'
import { type Root } from 'react-dom/client'
import type { Ref } from 'vue'
import type { ExcalidrawProps } from '@excalidraw/excalidraw/types/types'
import { nextTick } from 'vue'
export interface Props extends ExcalidrawProps {}
const props = defineProps<Props>()
const excalidrawRef: Ref<HTMLDivElement | null> = ref(null)
let root: null | any = null
let root: null | Root = null
onMounted(async () => {
onMounted( () => {
nextTick(async () => {
if (excalidrawRef.value) {
root = (await import('react-dom/client')).createRoot(excalidrawRef.value)
const Excalidraw = (await import('@excalidraw/excalidraw')).Excalidraw
let _Excalidraw: any
const Excalidraw = await import('@excalidraw/excalidraw')
if (Excalidraw.default)
_Excalidraw = Excalidraw.default
else
_Excalidraw = Excalidraw.Excalidraw
root.render(React.createElement(_Excalidraw, props as any))
root.render(React.createElement(Excalidraw, props as any))
}
})
})
onBeforeUnmount(() => {
Expand Down

0 comments on commit f2c88d9

Please sign in to comment.