0
So I’m taking these values in Asyncstorage and they come from my database, so far so good, I take the const’s and I play in them the values I pulled. but I need to be able to edit this by the text entries, and I can’t change the value of them.
import React, { useState, useEffect } from 'react';
import { View, Text, TextInput, SafeAreaView, StyleSheet, Image, TouchableOpacity, KeyboardAvoidingView } from 'react-native';
import {css} from '../../style/Css'
import MenuAreaRestrita from '../../assets/components/MenuAreaRestrita';
import AsyncStorage from '@react-native-async-storage/async-storage';
export default function Editar({navigation}){
const[paciente_nome, setPaciente_nome] = useState()
const[paciente_cpf, setPaciente_Cpf] = useState(null)
useEffect(()=> {
async function getNo_completo(){
let response = await AsyncStorage.getItem('pacienteData');
let json = JSON.parse(response);
setPaciente_nome((json.no_completo).toString())
setPaciente_Cpf(json.nu_cpf)
}
getNo_completo();
})
return(
<View style={css.containerMenu}>
<MenuAreaRestrita title='Editar' navigation={navigation}/>
<Text style={css.textCadastro}> Insira os dados do paciente:</Text>
<TextInput style ={css.textInputCadastro}
placeholder ='Nome:'
editable={true}
value={(paciente_nome).toString()}
onChangeText ={text=>String(setPaciente_nome(text))}
/>
<TextInput style ={css.textInputCadastro}
placeholder ='CPF:'
editable
value={formataCPF(String(paciente_cpf))}
onChangeText ={text=>setPaciente_Cpf(text)}
/>
</View>
)
}
What returns on this line? Let json = JSON.parse(Answer);
– Marconi
patient data. But anyway the error was in useEffect, I faltered and it turned out that this function was being called all the time, so I could n update
– beatriiss
is even missed to put the array [] there in its dependencies. put an answer there can help other users.
– Marconi
Really, I’ll do it. VLW
– beatriiss