🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 高阶组件 高阶组件(HOC)是react中对组件逻辑进行重用的高级技术。但高阶组件本身并不是React API。它只是一种模式,这种模式是由react自身的组合性质必然产生的。 具体而言,**高阶组件就是一个函数,且该函数接受一个组件作为参数,并返回一个新的组件** - [高阶组件文档介绍](https://react.docschina.org/docs/higher-order-components.html) - [render props](https://react.docschina.org/docs/render-props.html) ## 其他 ``` // 设置组件的值类型 static propTypes = { value: PropTypes.object, options: PropTypes.array, onChange: PropTypes.func, children: PropTypes.func }; // 设置默认的属性值 static defaultProps = { value: null, options: [], onChange: () => {}, children: () => {} }; ``` ## 参考文档 - [极客课程链接](https://github.com/supnate/react-geek-time)