overleaf/services/web/frontend/js/shared/hooks/use-wait-for-i18n.ts

21 lines
466 B
TypeScript
Raw Normal View History

import { useEffect, useState } from 'react'
import i18n from '../../../js/i18n'
import { useTranslation } from 'react-i18next'
function useWaitForI18n() {
const { ready: isHookReady } = useTranslation()
const [isLocaleDataLoaded, setIsLocaleDataLoaded] = useState(false)
useEffect(() => {
i18n.then(() => {
setIsLocaleDataLoaded(true)
})
}, [])
return {
isReady: isHookReady && isLocaleDataLoaded,
}
}
export default useWaitForI18n