Javascript TypeError:无法读取属性';createContext';未定义的

Javascript TypeError:无法读取属性';createContext';未定义的,javascript,reactjs,react-redux,next.js,package.json,Javascript,Reactjs,React Redux,Next.js,Package.json,我正在尝试使用npm run build来构建我的应用程序 我得到的错误是 TypeError:无法读取未定义的属性“createContext” 在检查解决方案后,我做了以下更改 我尝试将react和react dom升级到^16.4。 仍然得到相同的错误 我已在组件中定义为react.default.createContext() 我在组件中执行了控制台操作,发现react.default未定义 错误就发生在这一部分 "use strict"; Object.defineProperty(e

我正在尝试使用npm run build来构建我的应用程序

我得到的错误是
TypeError:无法读取未定义的属性“createContext”

在检查解决方案后,我做了以下更改

我尝试将react和react dom升级到^16.4。 仍然得到相同的错误

我已在组件中定义为react.default.createContext() 我在组件中执行了控制台操作,发现react.default未定义

错误就发生在这一部分

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
const initStore = {
    i18n: {},
    query: {}
};
exports.AppContext = react_1.default.createContext(initStore);
exports.withAppContext = (Children) => {
    return class App extends react_1.default.Component {
        static async getInitialProps(ctx = {}) {
            if (Children.hasOwnProperty('getInitialProps')) {
                const context = Object.assign(ctx, {});
                const childProps = (await Children.getInitialProps(context)) || {};
                return Object.assign(childProps, {});
            }
            else {
                return {};
            }
        }
        render() {
            return <exports.AppContext.Consumer>{app => <Child {...this.props} app={app}/>}</exports.AppContext.Consumer>;
        }
    };
};


这是某种版本问题吗?我使用Nextjs作为react之上的框架,我猜钩子是在16.8中引入的。
react.default.createContenxt()
似乎是一个打字错误,我建议你@Jai我已经更新了我的包。json react到16.8,我仍然收到同样的错误。我用过
exports.WebContext=react\u 1.default.createContext(store)
thanks@Jai事件升级到正确版本后,我仍然遇到问题。什么是最理想的解决方案。它不是应该是
react_1.createContext
而不是
react_1.default.createContext
{
  "name": "next-web",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "browser": {
    "fs": false,
    "child_process": false,
    "fork": false
  },
  "fork": false,
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@types/react-transition-group": "^4.2.3",
    "alertifyjs": "^1.13.1",
    "apollo-cache-inmemory": "^1.6.5",
    "apollo-client": "^2.6.8",
    "apollo-link": "^1.2.13",
    "apollo-link-context": "^1.0.19",
    "apollo-link-error": "^1.1.12",
    "apollo-link-http": "^1.5.16",
    "apollo-link-retry": "^2.2.15",
    "apollo-link-timeout": "^1.4.0",
    "apollo-link-ws": "^1.0.19",
    "apollo-utilities": "^1.3.3",
    "aws-xray-sdk-core": "^2.5.0",
    "babel-plugin-root-import": "^6.4.1",
    "child_process": "^1.0.2",
    "crypto-js": "^3.1.9-1",
    "ctrip-apollo": "^4.4.3",
    "date-fns": "^2.9.0",
    "fs": "0.0.1-security",
    "graphql": "^14.6.0",
    "graphql-hooks-memcache": "^1.3.1",
    "graphql-tag": "^2.10.1",
    "isomorphic-fetch": "^2.2.1",
    "jquery-param": "^1.0.2",
    "js-cookie": "^2.2.1",
    "koa": "^2.11.0",
    "koa-bodyparser": "^4.2.1",
    "koa-router": "^8.0.6",
    "memcached": "^2.2.2",
    "next": "^9.0.1",
    "next-config": "^0.1.0",
    "next-routes": "^1.4.2",
    "next-server": "^9.0.5",
    "polished": "^3.4.4",
    "qrcode": "^1.4.4",
    "react": "^16.12.0",
    "react-adopt": "^0.6.0",
    "react-apollo": "^3.1.3",
    "react-app-rewired": "^2.1.5",
    "react-copy-to-clipboard": "^5.0.2",
    "react-day-picker": "^7.4.0",
    "react-dnd": "^10.0.2",
    "react-dnd-html5-backend": "^10.0.2",
    "react-dom": "^16.12.0",
    "react-lazyload": "^2.6.5",
    "react-progressive-image": "^0.6.0",
    "react-slick": "^0.25.2",
    "react-transition-group": "^4.3.0",
    "styled-components": "^5.0.0",
    "styled-tools": "^1.7.1",
    "subscriptions-transport-ws": "^0.9.16",
    "ua-parser-js": "^0.7.21",
    "webpack-node-externals": "^1.7.2",
    "ycb": "^2.1.1"
  },
  "devDependencies": {
    "babel-preset-es2015": "^6.24.1",
    "react-dev-utils": "^10.1.0"
  }
}