Tldraw/hooks/useLoadOnMount.ts

17 wiersze
343 B
TypeScript
Czysty Zwykły widok Historia

2021-06-17 10:43:55 +00:00
import { useEffect } from 'react'
import state from 'state'
export default function useLoadOnMount() {
useEffect(() => {
2021-06-17 10:43:55 +00:00
const fonts = (document as any).fonts
fonts
.load('12px Verveine Regular', 'Fonts are loaded!')
.then(() => state.send('MOUNTED'))
2021-05-17 21:27:18 +00:00
return () => {
2021-06-17 10:43:55 +00:00
state.send('UNMOUNTED')
2021-05-17 21:27:18 +00:00
}
}, [])
}