Created
August 30, 2018 14:05
-
-
Save diego3g/d06da4d6d97a024afe4b60f56fa008b7 to your computer and use it in GitHub Desktop.
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
// Com flow | |
import * as React from 'react'; | |
type Props = { | |
type: string, | |
children: React.Node, | |
}; | |
type State = { | |
count: number, | |
}; | |
export default class Button extends Component<Props, State> { | |
state = { | |
counter: 0, | |
}; | |
updateCounter = () => { | |
this.setState(state => ({ counter: state.counter + 1 })); | |
}; | |
render() { | |
return ( | |
<button onClick={this.updateCounter} type={this.props.type}> | |
{this.props.children} | |
</button> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment