ReactJs多个函数调用内联

时间:2016-08-16 17:30:56

标签: javascript reactjs

我的目标是在onClick上调用多个函数。假设其中一些已经采用了事件和一些值,因此无法在单个函数中调用它们。我怎样才能做到这一点?

render() {
    //describe first function (1)
    const amountSelectClearInput = function(event) {
        // call two functions here
        this.amountSelect(event);
        this.clearInput();
    }.bind(this);
    var self = this;
    return (
        <div>
            <div>
                {amounts.map(function (name, index) {
                    return <input type="button" value={name}
                                  className={self.state.active === name ? 'active' : ''}
                                  //here I must call () => self.changeClass(name) (1), and amountSelectClearInput (2)
                                  onClick={() => self.changeClass(name)} key={ name }/>;
                })}
            </div>
        </div>
    );
}

我需要同时致电amountSelectClearInput() => self.changeClass(name)

1 个答案:

答案 0 :(得分:0)

onClick={function() { amountSelectClearInput(event);  self.changeClass(name)}}