我知道我可以在事件处理程序中放置多个函数,如下所示:
onClick={() => {function1(); function2()}}
如果我在事件处理程序中需要两个道具,可以用同样的方式完成吗?
onClick={() => {this.props.prop1(); this.props.prop2()}}
或者它们应该先组合成一个道具吗?
答案 0 :(得分:1)
合并它们会提高可读性
combinedFunction(){
this.props.prop1();
this.props.prop2()
}
onClick={this.combinedFunction}