[React] Define defaultProps and PropTypes as static methods in class component

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[React] Define defaultProps and PropTypes as static methods in class component相关的知识,希望对你有一定的参考价值。

class Toggle extends Component {
  static propTypes = {
    defaultOn: PropTypes.bool,
    on: PropTypes.bool,
    onToggle: PropTypes.func,
    children: PropTypes.oneOfType([
      PropTypes.func,
      PropTypes.array
    ]).isRequired,
  }
  static defaultProps = {
    defaultOn: false,
    onToggle: () => {},
  }
}

 

以上是关于[React] Define defaultProps and PropTypes as static methods in class component的主要内容,如果未能解决你的问题,请参考以下文章

[React] Define defaultProps and PropTypes as static methods in class component

微信公众号爬坑(react)

180React15.6.0ReactDOM15.6.0和React-Redux.4.0.0.js源码结构

React 组件自动绑定

解决node is not define

React classSet 不起作用 - Reactjs