我最近一直在玩React,遇到了这个错误:
未捕获的TypeError:无法读取属性' object'未定义的 at Object.defineProperty.value(app.js:33843) 在 webpack_require (app.js:20) at Object.defineProperty.value(app.js:33752) 在 webpack_require (app.js:20) 在对象。 (app.js:5250) 在 webpack_require (app.js:20) 在app.js:63 在app.js:66
我注意到这与propTypes有关,在所有拥有它们的组件中都有。如果我从一个组件中删除propTypes块,则另一个组件会出现类似的错误。
Base.propTypes = {
children: PropTypes.object.isRequired
};
我的package.json:
{
"name": "mernapp",
"version": "1.0.0",
"description": "test app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --use_strict index.js",
"bundle": "webpack"
},
"author": "Gytis Gecevicius",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.2",
"material-ui": "^0.19.4",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-router": "^4.2.0",
"react-tap-event-plugin": "^3.0.2",
"validator": "^9.1.1"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"nodemon": "^1.12.1",
"webpack": "^3.8.1"
}
}