Is the call to super(props) in an ES6 class important?

后端 未结 1 1803
后悔当初
后悔当初 2020-12-16 01:06

Suppose I\'ve the following class:

class Tabs extends React.Component {
  displayName: Tabs;

  static propTypes = {
  selected: React.PropTypes.number,
  ch         


        
1条回答
  •  一生所求
    2020-12-16 01:51

    According to Sophie Alpert with the React team it's only necessary to pass props into the constructor if you intend on using this.props inside the constructor. After the constructor is invoked, React attaches the props to the component from the outside.

    0 讨论(0)
提交回复
热议问题