distums / distums.github.io

my personal blog
https://distums.github.io/
0 stars 0 forks source link

HighOrderComponent #17

Open distums opened 7 years ago

distums commented 7 years ago
  1. 高阶组件在需要额外属性的时候需要额外的字段表示
distums commented 7 years ago
function Hoc(componentCreator) {
     return function ACom (props) {
          return (
             <div>
                {componentCreator(props)}
            </div>   
        );
    }
}

const componentCreator = (props) => <B {...props}/>

const Comp = Hoc(componentCreator);

<Comp />