Last active
March 30, 2020 17:03
-
-
Save akexorcist/70ed1091d3737860d91abf839238550c to your computer and use it in GitHub Desktop.
Code Snippet for https://blog.nextzy.me/เมื่อเขียน-react-แต่ดันไม่รู้เรื่อง-method-binding-ใน-react-component-6a498f3f646f
This file contains hidden or 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
| import React, { Component } from 'react' | |
| ... | |
| class UserCard extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| name: 'Akexorcist' | |
| } | |
| } | |
| onButtonClick() { | |
| console.log('Name : ' + this.state.name) | |
| } | |
| render() { | |
| return ( | |
| <div> | |
| ... | |
| <button onClick={this.onButtonClick}>Confirm</button> | |
| </div> | |
| ) | |
| } | |
| } | |
| export default UserCard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment