Last active
March 25, 2019 06:51
-
-
Save ShaileshPrajapati-BTC/72ad59fbf16a8a629493c5d4122c6cad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, PureComponent } from 'react'; | |
import { StyleSheet, Text, View, TouchableOpacity, Platform, Image } from 'react-native'; | |
import ImagePicker from 'react-native-image-picker'; | |
export default class CaptureImage extends PureComponent { | |
constructor(props) { | |
super(props); | |
this.state = { | |
picSource: null | |
} | |
} | |
componentDidMount() { | |
setTimeout(() => { | |
this._takePic(); | |
}, 2000); | |
} | |
_takePic = () => { | |
ImagePicker.launchCamera({}, (response) => { | |
this.setState({ | |
picSource: response.uri, | |
fileInfo: response, | |
imgUrl: response.uri, | |
imageUpload: true | |
},() => { | |
// Upload image code | |
})) | |
}); | |
} | |
render() { | |
if (this.state.picSource) | |
return ( | |
<View style={{ margin: 28, padding: 3, marginTop: 3, borderWidth: 1, borderColor: '#D8D8D8' }}> | |
<Image | |
source={{ uri: this.state.picSource }} | |
style={{ | |
alignSelf: 'center', | |
width: '100%', | |
height: 280, | |
}} | |
/> | |
</View>) | |
else | |
return(<View/>) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment