Skip to content

Instantly share code, notes, and snippets.

@codebucks27
Created February 3, 2021 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codebucks27/4ba593d311b72b9e83243c7461fa7c86 to your computer and use it in GitHub Desktop.
Save codebucks27/4ba593d311b72b9e83243c7461fa7c86 to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
const HOC = (Component, data) => {
//console.log("data", data);
return class extends React.Component {
constructor(props) {
super(props);
this.state = {
count: data,
};
}
handleClick = () => {
this.setState({
count: this.state.count + 1,
});
};
render() {
return (
<Component
CountNumber={this.state.count}
handleCLick={this.handleClick}
/>
);
}
};
};
export default HOC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment