Use Weather Data

Learn to read the data and use the optional chaining.

Let’s use the data prop from the last lesson to display the city’s weather information. The data received from the API is in the form of objects, as we saw in the console in the Use InputCity Component lesson. As a result, each piece of information used in this component is a property of the data object. The following snippets show how we extract and use the different properties from the data object. Let’s destruct the data object in the parameter itself.

const ShowWeather= ({ data }) =>{
   ...
}

Optional chaining

We’ll employ the ternary operator here, though we don’t use it to get the value of the properties from our ...