高阶组件并不是一个组件,而是一个函数

这个函数返回值是一个组件,并且接受一个组件做为参数;并且返回一个新组件;

function HighOC(WrapComponent){   //定义一个高阶组件 ,接受一个组件做为参数
     return class A extends React.Component{
          render(){
             <div>
                    <WrapComponent/>   
            </div>
        }  
     }  
}
export default HighOC;

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-08
  • 2022-01-20
  • 2021-12-10
  • 2021-12-20
相关资源
相似解决方案