class LoggingButton extends React.Component { handleClick = () => { console.log('this is:', this) } render() { return ( <button onClick={this.handleClick}> Click me </button> ) } }
class LoggingButton extends React.Component { constructor () { super(props) this.handleClick = this.handleClick.bind(this) } handleClick () { console.log('this is:', this) } render() { return ( <button onClick={this.handleClick}> Click me </button> ) } }
哪种写法运行效率更高?