Created
November 30, 2019 19:27
-
-
Save 01Clarian/8f36cb5781940dc0eef736abd95efc0c to your computer and use it in GitHub Desktop.
HOC to enhance Click and Hover Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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