CodingNic

Connect WeatherNow to the Weather API

Render the First API Response

Connect WeatherNow to the Weather API 10 min read

Render the First API Response

Task

Store and conditionally render the current response.

File / section

src/App.jsx

Change

Add const [weather, setWeather] = useState(null);. In loadWeather, after the successful response, call setWeather(current). In the JSX, replace the unconditional <Welcome /> with a conditional that renders the weather area when weather exists and Welcome otherwise.

Why this change matters

The API response is now the source of truth for whether the dashboard has weather data.

Test it

Search for a valid city and inspect the React-rendered page. You should see the weather area placeholder or current component once wired in.

Checkpoint

A successful API response is stored in React state and controls the main content.