Reputation: 1150
When capturing the photo using react-native-image-picker and saving it, the whole app is being reloaded sometimes. This is not happening all the time, sometimes it is working as expected, but sometimes its reloading the app.
ImagePicker.launchCamera(options, (response) => {
this.setState({ fileUri: response.uri, fileName: response.fileName })
});
"react-native": "0.59.1", "react-native-image-picker": "^0.26.10",
Upvotes: 2
Views: 1689
Reputation: 36
I was able to fix it by adding android:requestLegacyExternalStorage="true"
to application tag in AndroidManifest.xml
file
Upvotes: 2
Reputation: 1568
You can save the response to another variable rather than the state. It will not re-render the component.
fileDetails
ImagePicker.launchCamera(options, (response) => {
this.fileDetails = {
fileUrl = response.uri,
fileName = response.fileName
}
});
UploadImage(){
// Use the fileDetails here
}
Upvotes: 0