react-native - react-native : 图像裁剪选择器 onPress 取消
问题描述
我正在使用react-native-image-crop-picker并想知道如何 setState when cancel button is pressed
。有没有办法在cancel button
按下时调用函数?
解决方案
您可以在 .catch 方法中使用 setState,因为 openPicker 返回一个承诺。
ImagePicker.openPicker({
width: 300,
height: 400,
cropping: true
}).then(image => {
// Here you handle the image
}).catch(err => {
// Here you handle if the user cancels or any other errors
})
推荐阅读
- r - 使用填充函数 ggplot 时内核崩溃
- android - 在后台从 BroadcastReceiver 启动 Android 服务
- google-maps - Google Maps API 返回缩小的重复地球视图 - 坐标可能不正确?
- ionic-framework - 更改 *ngFor 中的 ion-col 断点
- sql-server - 日期函数不使用 SQL Server 存储过程返回 SSRS 中的所有结果
- c++ - 编译器是否真的使用我的“omp declare simd”函数?
- python - 如何使用另一个列表拆分列表
- vuejs2 - 如何纠正实现 vue-social-sharing、vuejs 的错误?
- python - 通过 SQL 代码循环 Python 参数
- ios - awakeFromNib() 调用了两次