Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructor(props){
- super(props)
- this.state = {
- personName : '',
- }
- }
- goToHomePage = async() => {
- if(this.state.personName == ''){
- alert('Informe seu nome')
- }else{
- try {
- await AsyncStorage.setItem('name', this.state.personName)
- Actions.home()
- } catch(e){
- return e
- }
- }
- }
- render(){
- return(
- <View style={styles.container}>
- <Text style={styles.text}>
- Obrigado por nos ajudar no combate a dengue !
- </Text>
- <TextInput style={styles.input}
- placeholder="Informe seu nome"
- placeholderTextColor="#fff"
- onChangeText={(personName) => this.setState({personName})}
- value = {this.state.personName}
- />
- <TouchableOpacity style={styles.button}
- onPress = {this.goToHomePage}
- >
- <Text style={styles.buttonText}>
- Entrar
- </Text>
- </TouchableOpacity>
- </View>
- )
- }
- getData = async() => {
- try{
- const username = await AsyncStorage.getItem('name')
- if(username !== null){
- return username
- }
- }catch(e){
- return e
- }
- }
- render(){
- return(
- <View style={styles.container}>
- <Text style={styles.text}>
- {this.getData}
- </Text>
- </View>
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement