I have a button that removes photos, works very well inside a view, you can remove several photos (The result in the console)
this is the image on the cel
this is the code
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
Dimensions,
TouchableHighlight
} from 'react-native';
import { Actions } from 'react-native-router-flux';
import { Camera, Permissions } from 'expo';
const {height, width} = Dimensions.get('window');
class Teste extends Component {
state = {
hasCameraPermission: null,
type: Camera.Constants.Type.front,
camara: null
};
press = () => {
if (this.camera) {
this.camera.takePictureAsync({
base64: true,
quality: 0.5
}).
then(data => {
//console.log('data:image/jpg;base64,${data.base64}')
if (data.base64){
console.log("quite una foto");
}
//Actions.prueba() comentando esto, puedo obtener varias fotos
}).catch(e => console.log(e))
}
}
render() {
return (
<View style={height <= 650 && width <= 450? stylesMin.container : styles.container}>
{
<Camera
style={{ height: 300, width: 300 }}
type={this.state.type}
ref={ref => {
this.camera = ref;
}}>
</Camera>
}
<View style={height <= 650 && width <= 450? stylesMin.contTopRight : styles.contTopRight }>
<TouchableHighlight
onPress={() => this.press() }
activeOpacity={0.7}
style={height <= 650 && width <= 450? stylesMin.button : styles.button }
>
<Text style={height <= 650 && width <= 450? stylesMin.caja : styles.caja }>Photo</Text>
</TouchableHighlight>
</View>
</View>
);
}
}
export default Teste
Until then, I have no problem removing a photo, the problem comes when I add another route (I decompose the above code in action)
if (this.camera) {
this.camera.takePictureAsync({
base64: true,
quality: 0.5
}).
then(data => {
//console.log('data:image/jpg;base64,${data.base64}')
if (data.base64){
console.log("quite una foto");
}
Actions.prueba() //esta linea
}).catch(e => console.log(e))
}
remove a photo and I have a view like this
this is the logic that brings me back to the camera
volver = () => {
console.log("volvere a la foto");
Actions.test()
}
this is the image on the cel
when you return to the camera screen it looks like this
and this is what it prints, when trying to remove another photo