0

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",

Rajan
  • 1,512
  • 2
  • 14
  • 18
Sourav Dey
  • 1,051
  • 1
  • 13
  • 21

2 Answers2

1

I was able to fix it by adding android:requestLegacyExternalStorage="true" to application tag in AndroidManifest.xml file

Arghya Sadhu
  • 41,002
  • 9
  • 78
  • 107
yahya
  • 26
  • 1
0

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
}
Rajan
  • 1,512
  • 2
  • 14
  • 18