Skip to content

Instantly share code, notes, and snippets.

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