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

90
Vistas
setState not uodating on first call

  // Get location manually and fetch weather data
  getSearchLocation = (value) => {
    const weatherApiLink = `https://api.openweathermap.org/data/2.5/weather?q=${value}&appid=${apiKeys.weatherKey}&units=metric`;
this.setState({
      weatherApiLink,
      value
    })
    console.log(value)
    console.log(this.state.value)
    console.log(this.state.weatherApiLink)
  }

The getSearchLocation gets its value from other components using props and is run on the onClick function. when the above function is executed and we run the conslole.log(value) it returns the correct value but when we run console.log(this.state.value) it returns UNDEFINED on the first click, on the second click the state is updated

about 4 years ago · Juan Pablo Isaza
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