Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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