Boa noite. meu problema é o seguinte, tenho um arquivo em js que armazena um valor de uma propriedade com o Async Storage, e quero mostrar esse valor que foi armazenado em um outro arquivo js. Porem quando eu chamo essa função de ler o valor o react me dá um warning "Function are not valid as a react child..." E não mostra na tela o valor que foi digitado anteriormente
'''Arquivo que armazena'''
export default class Form extends Component{
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>
)
}
}
'''Arquivo que deveria mostrar o valor'''
export default class Home extends Component{
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>
)
}
}