当props通过react-redux连接函数时,WebStorm突出显示React组件

时间:2017-02-16 10:05:14

标签: reactjs redux webstorm react-redux

我有一个容器组件:

import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';

class MyComponent extends Component {
  static propTypes = {
     someEntities: PropTypes.object.isRequired
  }
  ....
}

export default connect(state => ({ someEntities: state.someEntities })(MyComponent)

所以我通过connect将道具传递给这个组件,但当我将组件放在代码中时,如:

....
import MyComponent from './MyComponent';
....
<div><MyComponent /></div>
....

WebStorm突出显示MyComponent并向我显示错误:Element MyComponent doesn't have required attribute someEntities

我使用的是版本2016.3.1。这是一个错误吗?在这种情况下我应该使用propTypes吗?

1 个答案:

答案 0 :(得分:7)