Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. class Button extends Component {
  4. constructor(props) {
  5. super(props);
  6. this.state = { counter: 0 };
  7. }
  8.  
  9. increment = () => {
  10. const { counter } = this.state;
  11. this.setState({ counter: counter + 1 });
  12. }
  13.  
  14. render() {
  15. const { counter } = this.state;
  16. return <button type="button" onClick={this.increment}>{counter}</button>;
  17. }
  18.  
  19. }
  20.  
  21. export default Button;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement