I used react-native-image-picker;
import { launchImageLibrary } from 'react-native-image-picker';
And when I top add img, but close window I had a error TypeError: undefined is not an object (evaluating 'response.assets[0]')
My code:
launchImageLibrary(options, (response) => {
if (response) {
let base64 = response?.assets[0]?.uri;
dispatch({
type: 'SET_PHOTO',
payload: {
photo: base64, photoNumber, photoType,
}
})
}
});
https://i.stack.imgur.com/wtOXg.png
What should I do? What kind of check to write? This only happens when you press button add photo from photo gallery, but changed my mind and closed the dialog window