Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

90
Visualizações
TextInput return type in React Native

I was trying to update firebase database with useState that got its value from TextInput. But apparently the useState datatype changed to object instead of string. How do I go about this since firebase only takes string to update the database.

 const UpdateUser = async () => {
try {
  db.ref("users/" + auth.currentUser.uid).update({
    name: newuser,
  });
} catch (error) {
  alert(error);
}
setNewuser("");};

TextInput Code:

 <View>
    <Text style={styles.ProfileName}>Display Username:</Text>
    <TextInput
      placeholder={user}
      value={newuser}
      onChange={(text) => {
        setNewuser(text);
      }}
    />
    <Button onPress={UpdateUser} title="Change" />
  </View>
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

onChangeText is a simple prop, that gives whatever is the value of the input field on every change.//string

onChange passes an event with { nativeEvent: { eventCount, target, text} }. //object

You can find more about the difference here. Simply change it to onChangeText will work.

about 4 years ago · Juan Pablo Isaza Relatório

0

Change onChange to OnChangeText then it will work

refer this

about 4 years ago · Juan Pablo Isaza Relatório

0

Try this

<View>
    <Text style={styles.ProfileName}>Display Username:</Text>
    <TextInput
      placeholder={user}
      value={newuser}
      onChange={(e) => {
        setNewuser(e.target.value);
      }}
    />
    <Button onPress={UpdateUser} title="Change" />
  </View>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda