Fe-interview: [react] 使用高阶组件(HOC)实现一个loading组件

Created on 16 Jul 2019  ·  1Comment  ·  Source: haizlin/fe-interview

[react] 使用高阶组件(HOC)实现一个loading组件

react

Most helpful comment

function HOC(wrappedComponent) {
   return class extends React.Component {
      render() {
         if(!this.props.data) {
           return (<div>loading</div> )
         }
         return <wrappedComponent  {...this.props}/>

      }
   }
}

>All comments

function HOC(wrappedComponent) {
   return class extends React.Component {
      render() {
         if(!this.props.data) {
           return (<div>loading</div> )
         }
         return <wrappedComponent  {...this.props}/>

      }
   }
}
Was this page helpful?
0 / 5 - 0 ratings