'React - ES6 way' of binding click handlers with parameters

后端 未结 5 2078
暗喜
暗喜 2021-02-09 12:52

I\'ve read a bunch of articles about the use of () => {} syntax, binding in the constructor, binding in the props etc.. but from what I understand, binding

5条回答
  •  一整个雨季
    2021-02-09 13:29

    Does this work? (Using TypeScript)

    ;
    ;
    
    
    interface IOnPasswordInputChange {
      (value: string): void;
    }
    
    private onPasswordInputChange = (type: string): IOnPasswordInputChange => {
      return (value: string) => {
        this.setState({ [type]: value });
      };
    }
    

提交回复
热议问题