TypeError:无法创建数据属性〜React〜ESLint

问题描述 投票:0回答:1

[在某些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中。

javascript reactjs eslint static-analysis static-code-analysis
1个回答
0
投票

我会说你的问题可能是重复的property1:

MyComponent.defaultProps = {
  property1: null, // remove this one
  loading: true,
  property1: [], // or this one
  property2: null
}
© www.soinside.com 2019 - 2024. All rights reserved.