import React from 'react';
function Child(props){
return <div>Child</div>
}
const foo = Cmp => props => {
return <Cmp {...props}/>
}
const foo = Cmp => {
return props => {
return <Cmp {...props}/>
}
}
export default function HocPage(props) {
const Foo = foo(Child);
return (
<div>
HocPage
<Foo/>
</div>
)
}
注意:装饰器写法:
1、装饰器只能用在class组件上
2、执行顺序从下往上
例:
@withLog
@withContent