我在班级中有一个特定于应用程序的Arrow函数,我想在按下Button后调用此函数 所以有两种我不了解它们之间差异的方法
代码
selectPhotoTapped = () => {
ImagePicker.showImagePicker(options, response => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled photo picker');
} else {
let source = {uri: response.uri};
this.setState({
avatarSource: source,
});
}
});
};
// First One
<TouchableOpacity onPress={this.selectPhotoTapped}>
<Text>Upload</Text>
</TouchableOpacity>
// Second One
<TouchableOpacity onPress={ () => this.selectPhotoTapped()}>
<Text>Upload</Text>
</TouchableOpacity>