-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeatherApp.jsx
More file actions
36 lines (31 loc) · 831 Bytes
/
Copy pathWeatherApp.jsx
File metadata and controls
36 lines (31 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { useState } from "react";
import InfoBox from "./ui/InfoBox";
import SearchBox from "./ui/SearchBox";
import "./WeatherApp.css";
const WeatherApp = () => {
/*
const [weatherInfo, setWeatherInfo] = useState({
city: "Delhi",
feelsLike: 24.84,
temp: 25.05,
tempMin: 25.05,
tempMax: 25.05,
humidity: 47,
weather: "haze",
});
*/
// Initialize state properly in WeatherApp
const [weatherInfo, setWeatherInfo] = useState(null);
const updateWetherInfo = (result) => {
setWeatherInfo(result);
};
return (
<div className="WeatherApp">
<h2>Meghya : Search for the Weather!</h2>
<SearchBox updateInfo={updateWetherInfo} />
{/* and render conditionally: */}
{weatherInfo && <InfoBox info={weatherInfo} />}
</div>
);
};
export default WeatherApp;