使用两者有什么区别,什么时候应该使用一个
<Button onPress={this.refreshData}>
<Button onPress={()=>this.refreshData()}>
最佳答案
如果您不需要将参数传递给您的函数,您应该这样做:
<Button onPress={this.refreshData}>
这样做 <Button onPress={()=>this.refreshData()}>
可能会破坏优化。
来自 React 文档:
Using an arrow function in render creates a new function each time the component renders, which may break optimizations based on strict identity comparison.
关于javascript - React Native Button onPress 函数示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69846105/