blade-sensei/learning

HOC react

Closed this issue · 2 comments

HOC react
import React from 'react';
export function WrappedAdd(WrappedComponent, {a, b}) {
   return class extends React.Component {
      constructor(props) {
      super(props);
    }
      render() {
         this.props.a = this.props.a++;
         this.props.b = this.props.b++;
       
         return <WrappedComponent a={this.props.a} b={this.props.b} />
      }
   }
}