Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

175
Vistas
React Native TextInput not updating state in a functional component using onhange

I am using a in a react native functional component and onChange the state does not seem to be updating for "name".

I am console logging the new state using useEffect to check whether or not the state is updated and it is returning undefined as if the input text was never set as the state "name"

function AddTask ()  {
    
    const [name, setName] = useState('');
  
    useEffect(() => {
        console.log(name),name;
        
    })

    const updateTaskInfo = event => setName(event.target.value);
    
        return (
             <TextInput
                  onChange={updateTaskInfo}
                  placeholder="Name"
                  value={name}
             />
 );
}

export default AddTask;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

use onChange like that event.nativeEvent.target.value

<TextInput onChange={ event => setName(event.nativeEvent.target.value) } />

or use onChangeText like that

<TextInput onChangeText ={ value => setName(value ) } />
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda