我在我的应用程序中更新了几个 npm
包并遇到了一堆我已经安全解决的错误,除了一个!
TypeError: Cannot read property 'any' of undefined
at Object.<anonymous> (/home/cpt/Desktop/prod/local/app/components/Base/react-quick-return.js:11:24)
at loader (/home/cpt/Desktop/prod/local/node_modules/babel-register/lib/node.js:144:5)
在下面的代码中:
/* eslint-disable */
import React, {PropTypes} from 'react';
import detectPassiveEvents from 'detect-passive-events';
import {getScrollTop, getSupportedCSSProperty} from 'utils/dom';
import cx from 'classnames';
const EVENTS = ['scroll', 'resize', 'load', 'pageshow'];
class QuickReturn extends React.Component {
static propTypes = {
component: PropTypes.any.isRequired, //HERE IS
className: PropTypes.string
};
我将 react
版本从 15.3.1
更改为 16.8.4
但是,我还更新了以下软件包:
"babel-core": "6.26.3",
"react": "16.8.4",
"react-addons-create-fragment": "15.6.2",
"react-addons-css-transition-group": "15.6.2",
"react-addons-pure-render-mixin": "15.6.2",
"react-dom": "16.8.4",
"react-maskedinput": "4.0.1",
"react-redux": "5.1.0",
"react-router": "3.2.0",
"redux": "4.0.0",
"react-addons-test-utils": "15.6.2",
据我所知,问题出在 babel-register
模块,但它不在我的 package.json
请告诉我,这可能是怎么回事?我到了谷歌的第 5 页,并决定在这里写。
最佳答案
PropTypes
不再存在于 react 中。现在是 import PropTypes from 'prop-types'
。
https://reactjs.org/docs/typechecking-with-proptypes.html
关于javascript - 类型错误:更新后无法读取未定义的属性 'any',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55619102/