[在某些React组件上使用ESLint时,我遇到类型错误,该错误会以消息TypeError: unable to create data property. Occurred while linting PATH/TO/MY/REACT/COMPONENT/mycomponent.js.jsx:54
终止ESLint。
代码看起来像这样:
class MyComponentextends React.Component {
... // Some component's logic.
}
// MyComponent.defaultProps is the line 54 to which the errors points out.
MyComponent.defaultProps = {
property1: null,
loading: true,
property1: [],
property2: null
}
该错误在声明了ANY_COMPONENT.defaultProps
的每个文件中都重复,但是找不到为什么的解释。该项目位于React 15.6.2
中。
我会说你的问题可能是重复的property1:
MyComponent.defaultProps = {
property1: null, // remove this one
loading: true,
property1: [], // or this one
property2: null
}