首页 > 解决方案 > Reactjs - 具有不同数量参数的 handleChange

问题描述

我正在尝试制作一个可编辑的简单数据表。

本质上,我想弄清楚我的handleChange函数是否可以接受不同数量的参数?

例如,有没有办法我可以做这样的事情并能够从我的TextInput?

<TextInput
          name={this.props.headers[i-1].id}
          onChange={(event) => this.onInputChange(row.id, this.props.headers[i-1].id, event)}
          disabled={(this.isBeingEdited(row.id) === false)}
          value={row[rowKeys[i]]}
/>

TextInputhandleChange看起来像这样:

handleChange = event => {
    var value = event.target.value;
    this.setState({ value: value }, () => this.checkForErrors());
    this.props.onChange(this.props.name, value);
}

现在,它只是给我this.props.namevalue但我也想要row.id

谢谢你的帮助!

标签: reactjs

解决方案


推荐阅读