How to fix ''TypeError: createContext is not a function"

Viewed 4593

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 Answers

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
Related