Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

react fetch data (weather)

interface WeatherDisplayProps {
  location: string;
}
const WeatherDisplay: FC<WeatherDisplayProps> = ({ location }) => {
  const [weather, setWeather] = useState<number>();
  useEffect(() => {
    const fetchWeather = async () => {
      const response = await WeatherAPI.getWeather(location);
      setWeather(response.celsius);
    };
    fetchWeather();
  }, [location]);
return (
    <div>
      <h1>Weather</h1>
      <p>
        Today weather in {location} is {weather} celsius{" "}
      </p>
    </div>
  );
};
export default WeatherDisplay;
Comment

PREVIOUS NEXT
Code Example
Typescript :: which electromagnetic radiation is used for heating and night vision equipment 
Typescript :: react static typescript properties 
Typescript :: can blue jays tickets still be printed 
Typescript :: sorting list of multiple in an ascending order 
Typescript :: ts repeat string 
Typescript :: re initialize weights keras 
Typescript :: get_refreshed_fragments too long to load 
Typescript :: typescript object annotation 
Typescript :: sarasota bowling alley bomb threats incident 
Typescript :: install beats on rasberry 
Typescript :: input non-negative decimal in typescript 
Typescript :: routerextensions nativescript 7 import 
Typescript :: calling from a list elements in steps 
Typescript :: Passing Data between fragments in Android using Interface 
Typescript :: combine 2 lists to dataframe python 
Typescript :: distance between two lat long points google maps api 
Typescript :: top data scientists in the world 
Typescript :: Coding Exercise: Double Time Modify this recursive program to correctly count down in increments of 2. 
Cpp :: cpp boilerplate 
Cpp :: if vector contains value c++ 
Cpp :: conditional cout in c++ 
Cpp :: how to iterate through a map in c++ 
Cpp :: add arbitrum to metamask 
Cpp :: 2114. Maximum Number of Words Found in Sentences leetcode solution in c++ 
Cpp :: you wanna import math on c++ 
Cpp :: multiply image mat by value c++ 
Cpp :: retourner pointeur de type qstringlist qt 
Cpp :: draw rect outline sdl2 
Cpp :: set precision in c++ 
Cpp :: C compile SDL program using mingw 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =