Explorar o código

fix: remove tln after unmount

Peng Xiao %!s(int64=3) %!d(string=hai) anos
pai
achega
0d8477534f
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  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 { TLAppPropsWithoutApp, TLAppPropsWithApp } from '~components'
 import type { TLReactShape, TLReactApp } from '~lib'
 import type { TLReactShape, TLReactApp } from '~lib'
 
 
-declare const window: Window & { tln: TLReactApp<any> }
+declare const window: Window & { tln?: TLReactApp<any> }
 
 
 export function useSetup<
 export function useSetup<
   S extends TLReactShape = TLReactShape,
   S extends TLReactShape = TLReactShape,
@@ -31,6 +31,7 @@ export function useSetup<
     if (onMount) onMount(app, null)
     if (onMount) onMount(app, null)
     return () => {
     return () => {
       unsubs.forEach(unsub => unsub())
       unsubs.forEach(unsub => unsub())
+      window['tln'] = undefined
     }
     }
   }, [app])
   }, [app])