// 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