Created
December 6, 2022 18:36
-
-
Save alic-xc/c799409d3592f42b3a88da65d8ab1d5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { | |
useGetCurrentWeatherQuery, | |
useGetWeatherForecastRangeQuery, | |
useSendWeatherDatautation, | |
} from "../services/weatherAPI"; | |
const Weather = () => { | |
const [date, setDate] = useState({ fromDate: "", toDate: "" }); | |
const { data: currentWeather, isFetching } = useGetCurrentWeatherQuery(); | |
const { data: WeatherForecastRange } = useGetWeatherForecastRangeQuery({ | |
fromDate: date.fromDate, | |
toDate: date.toDate, | |
}); | |
return ( | |
<> | |
<section> | |
{isFetching && <div>Loading...</div>} | |
{!isFetching && currentWeather && ( | |
<div> Current weather Data : {currentWeather}</div> | |
)} | |
</section> | |
<section> | |
{WeatherForecastRange && ( | |
<div> | |
Current weather Data range from {date.fromDate} to {date.toDate} : | |
{WeatherForecastRange} | |
</div> | |
)} | |
</section> | |
</> | |
); | |
}; | |
export default Weather; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment