I am new to React-Native(Expo). I want to take Image Capture, convert it to base64 and save it to state.
My code is like this:
return (
<View style={{ flex: 1 }}>
<Camera style={{ flex: 1 }} type={this.state.type}>
<View
style={{
flex: 1,
backgroundColor: 'transparent',
flexDirection: 'row',
}}>
<TouchableOpacity
style={{
flex: 0.1,
alignSelf: 'flex-end',
alignItems: 'center',
}}
onPress={() => {
Camera.takePictureAsync({
base64: true,
}).then(data => {
this.setState({base64:data.base64})
});
}}>
<Text style={{color: 'white' }}>
Capture
</Text>
</TouchableOpacity>
</View>
</Camera>
</View>
);
It says takePictureAsync() is not a function. Screenshot of my error is:
Does anyone have an idea about what is the problem? How can I Capture Image and save its base64 to state?