Skip to content

Instantly share code, notes, and snippets.

@diego3g
Created August 30, 2018 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diego3g/d06da4d6d97a024afe4b60f56fa008b7 to your computer and use it in GitHub Desktop.
Save diego3g/d06da4d6d97a024afe4b60f56fa008b7 to your computer and use it in GitHub Desktop.
// 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