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

105
Vistas
React Native (getting value from text input)

So I'm doing a little personal project and I'm having some trouble getting the numeric value from the textinput. I'm either getting an error saying the function expected a string or undefined.

Below is the source code:

//Timer state
  const [timer, setTimer] = useState({
    work: 0.3,
    break: 0.2,
    longBreak: 0.5,
    active: "work",
  });

  const workTime = timer.work;
  const breakTime = timer.break;
  const longBreakTime = timer.longBreak;

This is where the value is supposed to be passed :

function handleChange(name, value) {
    console.log(value);

    switch (name) {
      case "work":
        setTimer({ ...timer, work: parseInt(value) });
        break;
      case "break":
        setTimer({ ...timer, break: parseInt(value) });
        break;
      case "longBreak":
        setTimer({ ...timer, longBreak: parseInt(value) });
      default:
        break;
    }
  }

I'm trying to retrieve the value from this text input:

 <TextInput
              style={styles.input}
              onChange={(workTime) => handleChange("work", setTimer(workTime))}
              placeholder="Work"
              keyboardType="numeric"
              numeric
              value={workTime}
              name="work"
            />
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

onChange={(workTime) => handleChange("work", workTime)}

you are passing a call to the hook function instead of the value you read from the input

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