[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