首先,我们先来了解一下函数在正式高阶组件之前的类似操作:functionhello(){console.log('hello')}functionWrapperHello(fn){returnfunction(){console.log('before')fn&&fn()console.log('after')}}hello=WrapperHello(hello)hello()上面代码的输出会先输出before,再输出hello,然后finally之后,hello函数相当于在外面包裹了一层统一的逻辑然后返回,声明就是覆盖原来的hello函数,这是高层组件的基本原理。然后让我们写一个基本的高级组件来进行比较:具体到高阶组件
