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>
)
}
Note: how to write the decorator:
1. Decorators can only be used on class components
2. The execution order is from bottom to top
Example:
@withLog
@withContent