tldraw/hooks/useLoadOnMount.ts
2021-06-17 11:43:55 +01:00

16 lines
343 B
TypeScript

import { useEffect } from 'react'
import state from 'state'
export default function useLoadOnMount() {
useEffect(() => {
const fonts = (document as any).fonts
fonts
.load('12px Verveine Regular', 'Fonts are loaded!')
.then(() => state.send('MOUNTED'))
return () => {
state.send('UNMOUNTED')
}
}, [])
}