Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. function Counter(props) {
  2. return <div>
  3. <p>{{ props.number }}</p>
  4. <button onclick=props.onclick >Click Me</buton>
  5. </div>
  6. }
  7.  
  8. class CounterState extends React.Component {
  9.  
  10. constructor(props) {
  11. super(props)
  12.  
  13. this.state = { count: 0 };
  14. }
  15.  
  16. render() {
  17. <Counter number={this.state.count} onclick={this.handleClick} />
  18. }
  19.  
  20. handleClick() {
  21. this.setState({ count: this.state.count + 1});
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement