You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useLoadOnMount.ts 584B

12345678910111213141516171819202122
  1. /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
  2. import { useEffect } from 'react'
  3. import state from 'state'
  4. export default function useLoadOnMount(roomId?: string) {
  5. useEffect(() => {
  6. const fonts = (document as any).fonts
  7. fonts.load('12px Verveine Regular', 'Fonts are loaded!').then(() => {
  8. state.send('MOUNTED')
  9. if (roomId !== undefined) {
  10. state.send('RT_LOADED_ROOM', { id: roomId })
  11. }
  12. })
  13. return () => {
  14. state.send('UNMOUNTED')
  15. state.send('RT_UNLOADED_ROOM', { id: roomId })
  16. }
  17. }, [roomId])
  18. }