tldraw/hooks/useLoadOnMount.ts
2021-06-21 22:35:28 +01:00

17 lines
414 B
TypeScript

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
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')
}
}, [])
}