Created
November 30, 2019 19:08
-
-
Save 01Clarian/6f6048bcf5159152fdfc63218423d2df to your computer and use it in GitHub Desktop.
HoverCounter Pre HOC
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'; | |
class HoverCounter extends React.Component { | |
constructor() { | |
super() | |
this.state = { | |
count: 0 | |
} | |
} | |
increment = () => { | |
this.setState(prevState => { | |
return {count: prevState.count + 1} | |
}) | |
} | |
render(){ | |
return ( | |
<h2 onMouseOver={props.increment}> | |
{props.count}</h2> | |
); | |
}} | |
export default HoverCounter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment