Здесь я устанавливаю значения по умолчанию для переменных внутри state > currentWeather
, как в следующем примере, затем снова я устанавливаю динамические значения для этих переменных, чтобы они работали для условий пользовательского поиска, когда статические значения в открытом приложении не отображаются, как я могу это исправитьтот?
class App extends Component {
state = {
currentWeather: {
currentLocation: 'Colombo',
currentDate: new Date(),
currentTempreture: 28.3,
currentWeatherLabel: 'rain',
currentWind: 1.5,
currentHumidity: 60
}
};
getWeather = async e => {
this.setState({
currentTempreture: data.main.temp,
currentLocation: data.name,
currentWind: data.wind.speed,
currentHumidity: data.main.humidity,
currentWeatherLabel: data.weather[0].description
});
};
render() {
return (
<div id="bsec" className="b-color body-sec">
<div className="main-wrapper">
<MainWidget
location={this.state.currentLocation}
date={this.state.currentDate}
tempreture={this.state.currentTempreture}
label={this.state.currentWeatherLabel}
wind={this.state.currentWind}
humidity={this.state.currentHumidity}
pressure={this.state.currentPressure}
/>
</div>
</div>
);
}
}