mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 20:23:45 -05:00
345f51bedb
* Defer script loading * Only mount IdePage once everything has connected GitOrigin-RevId: 32f16214f26ac6a6d71a9dd332b3c35b8b82deae
26 lines
591 B
TypeScript
26 lines
591 B
TypeScript
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)
|
|
const [error, setError] = useState<Error>()
|
|
|
|
useEffect(() => {
|
|
i18n
|
|
.then(() => {
|
|
setIsLocaleDataLoaded(true)
|
|
})
|
|
.catch(error => {
|
|
setError(error)
|
|
})
|
|
}, [])
|
|
|
|
return {
|
|
isReady: isHookReady && isLocaleDataLoaded,
|
|
error,
|
|
}
|
|
}
|
|
|
|
export default useWaitForI18n
|