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

170
Visualizações
pass multiple params onChangeText input element function - React native

I have multiple Input elements and everytime the user type into these Inputs I call handleChange() function which should tell what the user has written and which Input he has typed in.

This is what I have done:

handleChange(text, name) {
    console.log("test: "text+" "+name);
}

//http://facebook.github.io/react-native/releases/0.23/docs/textinput.html
for (var p = 0; p < 20; p++){
      products.push (<TextInput name={p} onChangeText={(text, name) => this.handleChange(text, name)}></TextInput> );
}

the console.log inside handleChange function correctly shows the text written by user but doesn't display correctly name variable which results undefined.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

What is name supposed to be? All you're doing is setting name to an integer, but here's a way to make it work:

handleChange(text, name) {
  console.log("test: "text+" "+name);
}

//http://facebook.github.io/react-native/releases/0.23/docs/textinput.html
for (let p = 0; p < 20; p++){
  products.push (<TextInput onChangeText={(text) => this.handleChange(text, p)}></TextInput> );
}
over 4 years ago · Santiago Trujillo Relatório

0

handleChange= (name) => {
return (text) => {
   console.log("test: "name+" "+text); 
}};

[https://hackernoon.com/curry-away-in-react-7c4ed110c65a][1]

for (let p = 0; p < 20; p++){
products.push (<TextInput onChangeText={this.handleChange(p)}> 
</TextInput> );
}
over 4 years ago · Santiago Trujillo 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