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

119
Vistas
value is not assigned to variable state in react native

Im new to react native. when I receive data from server and set the data to variable in alert nothing to show for me can help me to fix this? tank you

   const [result, setResult] = useState('')

    Server(mydata).then(data => {
    //data value is ok 
    //when set data value to setResult
    //dose not show anything in alert
    setResult(data.data)        
    alert(setResult)
   })
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Because setResult() is an async operation, you should be using useEffect to wait for the result and make the alert. Something like this:

const [result, setResult] = useState('')

Server(mydata).then(data => {
    //data value is ok 
    //when set data value to setResult
    //dose not show anything in alert
    setResult(data.data)
})

useEffect(() => {
    alert(result)
}, [result])
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