use-wait-for-i18n.ts 466 B

1234567891011121314151617181920
  1. import { useEffect, useState } from 'react'
  2. import i18n from '../../../js/i18n'
  3. import { useTranslation } from 'react-i18next'
  4. function useWaitForI18n() {
  5. const { ready: isHookReady } = useTranslation()
  6. const [isLocaleDataLoaded, setIsLocaleDataLoaded] = useState(false)
  7. useEffect(() => {
  8. i18n.then(() => {
  9. setIsLocaleDataLoaded(true)
  10. })
  11. }, [])
  12. return {
  13. isReady: isHookReady && isLocaleDataLoaded,
  14. }
  15. }
  16. export default useWaitForI18n