From the course: Master React 19 and Next.js 16 with Hands-On Projects and Real-World Applications

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Build the CurrentWeather component

Build the CurrentWeather component

Welcome to this session where we'll be building the current weather component for our React Weather app. This component will display the most important current weather information for a given location, such as temperature, feels like temperature, min-max temperatures, humidity, wind speed, and the current weather condition based on the weather code. to app.jxx. Now, you will see me add a comment explaining that I'll select a default city when the component first mounts. This sets the stage for what we'll do next. Let's add a UseEffect hook. This hook runs after the component renders. The empty dependency array ensures it only runs once. We'll use this to set our default city. Inside the UseEffect took, I am creating a default city object with name, country, latitude, and longitude properties. London is used as the default. I'm now using the setSelectedCity function to update the state with our default city. This will trigger a re-render with the default city's data. Going back to…

Contents