React Webpack: TypeError: react__WEBPACK_IMPORTED_MODULE_7___default.a.createContext

React Webpack: TypeError: react__WEBPACK_IMPORTED_MODULE_7___default.a.createContext

最近我将 i18next 库添加到我的 React 应用程序中。编译成功,但我在控制台中收到此 TypeError。

Uncaught TypeError: react__WEBPACK_IMPORTED_MODULE_7___default.a.createContext is not a function
    at eval (context.js:69)
    at Module../node_modules/react-i18next/dist/es/context.js (bundle.js:15948)
    at __webpack_require__ (bundle.js:20)
    at eval (withNamespaces.js:23)
    at Module../node_modules/react-i18next/dist/es/withNamespaces.js (bundle.js:15984)
    at __webpack_require__ (bundle.js:20)
    at eval (index.js:5)
    at Module../node_modules/react-i18next/dist/es/index.js (bundle.js:15960)
    at __webpack_require__ (bundle.js:20)
    at eval (i18n.js:11)

i18n 是来自 https://react.i18next.com/guides/quick-start 的示例。我在使用 create-react-app (React 16.7) 之前测试过它并且运行良好。在我的应用程序中,我使用的是 React 15.6 和 Redux,但它看起来像 Webpack 问题。

index.js

/*@ NODE MODULES  */
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';

/*@ LOCAL */
import i18n from './i18n';
import App from './components/App';
import configureStore from './store/configureStore';

const store = configureStore();

render(
    <Provider store={store}>
        <App />
    </Provider>,
    document.getElementById('mainApp')
);

package.json

...
"devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-plugin-lodash": "^3.3.2",
    "babel-plugin-syntax-object-rest-spread": "^6.13.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "chalk": "^2.3.0",
    "cross-env": "^5.1.1",
    "css-loader": "^0.23.1",
    "progress-bar-webpack-plugin": "^1.11.0",
    "style-loader": "^0.13.1",
    "webpack": "^4.16.1",
    "webpack-bundle-analyzer": "^3.0.2",
    "webpack-cli": "^3.0.8"
  },
...

我找到了解决方案。不同的 React 版本需要特定的 react-i18next 版本

 "react": "^15.6.2",
 "react-i18next": "^8.4.0",


"react": "^16.3.2",
"react-i18next": "^9.0.0",