Skip to content

Instantly share code, notes, and snippets.

@01Clarian
Created November 30, 2019 19:27
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 01Clarian/8f36cb5781940dc0eef736abd95efc0c to your computer and use it in GitHub Desktop.
Save 01Clarian/8f36cb5781940dc0eef736abd95efc0c to your computer and use it in GitHub Desktop.
HOC to enhance Click and Hover Component
import React from 'react'
const EnhanceComponent = (OrignComponent) => {
class ModComponent extends React.Component {
constructor() {
super()
this.state = {
count: 0
}
}
increment = () => {
this.setState(prevState => {
return {count: prevState.count + 1}
})
}
render() {
return (
<div><OrignComponent count={this.state.count}
increment={this.increment} /></div>
);
}
}
return ModComponent;
}
export default EnhanceComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment