2
votes

React-i18next createContext is not a function

Hello. I a troubleshoot with react-i18next for translate my app, during the import i18n.js in index.js, I a type error. I m not expert ReactJs and i not resolved this trouble with success, i need help please. Thanks

i18n.js:


    import i18n from 'i18next';
    import { initReactI18next } from 'react-i18next';
    
    import Backend from 'i18next-xhr-backend';
    import LanguageDetector from 'i18next-browser-languagedetector';
    
    i18n
      .use(Backend)
      .use(LanguageDetector)
      .use(initReactI18next)
      .init({
        fallbackLng: 'en',
        debug: true,
    
        interpolation: {
          escapeValue: false,
        }
      });
    
    export default i18n;

Error in consol:


    -> export var I18nContext = React.createContext();


    "Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_3_react___default.a.createContext is not a function"

2

2 Answers

0
votes

I fixed my problem :

run

npm install react@latest
and
npm install react-dom@latest
its worked for me

In package.json now reads

"react": "^16.8.6", "react-dom": "^16.8.6"

Visit https://github.com/hasura/react-check-auth/issues/7#issuecomment-484208398

0
votes

It is actually a version miss match so updating the your react-dom, react & redux packages would solve the issue

npm update react react-dom