Недавно я добавил библиотеку 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 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"
},
...