camerja
camerja copied to clipboard
Take picture, Expo client suddenly stopped
Hi,
i'm facing problem, when i take picture, Expo client suddenly stopped without error information
snap = async function(){
if (this.camera) {
this.camera.takePictureAsync().then(data => {
FileSystem.moveAsync({
from: data,
to: ${FileSystem.documentDirectory}photos/Photo_${this.state .photoId}.jpg
,
}).then(() => {
this.setState({
photoId: this.state.photoId + 1,
});
Vibration.vibrate();
});
});
}
};
how to display the error message?
Thanks
with this still can't show the error
try{ this.camera.takePictureAsync().then(data => { FileSystem.moveAsync({ from: data, to:
${FileSystem.documentDirectory}photos/Photo_${this.state .photoId}.jpg
, }).then(() => { this.setState({ photoId: this.state.photoId + 1, }); //Vibration.vibrate(); }); }); }catch(error) { console.log('Error Take pic : '+error); }
Hi, i had the same problem. FileSystem.moveAsync, change field "data" to "data.uri". This change solved problem in my case.
To display error add .catch() after .then()
this.camera.takePictureAsync()
.then((data) => {
FileSystem.moveAsync({
from: data.uri,
to: `${FileSystem.documentDirectory}photos/Photo_${this.state.photoId}.jpg`,
}).then(() => {
this.setState({
photoId: this.state.photoId + 1,
});
Vibration.vibrate();
})
.catch((e) => {
console.log(e, 'ERROR');
});
})
.catch((e) => {
console.log(e, 'takePicture ERROR');
});
Thanks For this Worked For me!
@mali3days you should submit a pull request for this!