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

128
Vistas
React Native I am having issues with adding a number from state

react native is not increasing my number by 2 instead it keeps append new text to my state. I don't have a problem when subtracting the problem is just with adding

const [vol, setVol] = useState(10)

useEffect(()=>{
  setVol(e=> e + 2)
},[])

console.log(vol)
// output 102

I need to increase the state vol (10) by 2 so output should be 12

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

e will be a string and hence will follow string addition change it to Number before adding const [vol, setVol] = useState(10)

useEffect(()=>{
  setVol(e=> String(Number(e) + 2))
},[])

console.log(vol)
// output 12
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