فهرست منبع

fix: remove tln after unmount

Peng Xiao 3 سال پیش
والد
کامیت
0d8477534f
1فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  1. 2 1
      tldraw/packages/react/src/hooks/useSetup.ts

+ 2 - 1
tldraw/packages/react/src/hooks/useSetup.ts

@@ -2,7 +2,7 @@ import * as React from 'react'
 import type { TLAppPropsWithoutApp, TLAppPropsWithApp } from '~components'
 import type { TLReactShape, TLReactApp } from '~lib'
 
-declare const window: Window & { tln: TLReactApp<any> }
+declare const window: Window & { tln?: TLReactApp<any> }
 
 export function useSetup<
   S extends TLReactShape = TLReactShape,
@@ -31,6 +31,7 @@ export function useSetup<
     if (onMount) onMount(app, null)
     return () => {
       unsubs.forEach(unsub => unsub())
+      window['tln'] = undefined
     }
   }, [app])