React不用重复绑定this函数写法

import React from 'react';
class IndexPage extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      testState: 1
    };
  }

  handleClick = (value) => (event) => {
    console.log('------------this: ', this);
    console.log('------------event: ', event);
    console.log('------------value: ', value);
  }
  render() {
    return (
      <div>
        <button onClick={this.handleClick('点击')}>箭头函数</button>
      </div>
    );
  }
}

export default IndexPage;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容