使用react-native-image-picker捕获照片并保存时,有时会重新加载整个应用程序。这并非一直都在发生,有时它会按预期运行,但有时会重新加载应用程序。
ImagePicker.launchCamera(options, (response) => {
this.setState({ fileUri: response.uri, fileName: response.fileName })
});
“ react-native”:“ 0.59.1”, “ react-native-image-picker”:“ ^ 0.26.10”,
答案 0 :(得分:1)
我能够通过将android:requestLegacyExternalStorage="true"
添加到AndroidManifest.xml
文件中的应用程序标记中来修复它
答案 1 :(得分:0)
您可以将响应保存到另一个变量而不是状态。不会重新渲染组件。
fileDetails
ImagePicker.launchCamera(options, (response) => {
this.fileDetails = {
fileUrl = response.uri,
fileName = response.fileName
}
});
UploadImage(){
// Use the fileDetails here
}