import React from "react"; import PropTypes from "prop-types"; import WeatherSunny from "./WeatherSunny"; import WeatherRainy from "./WeatherRainy"; import WeatherCloudy from "./WeatherCloudy"; export default function WeatherDisplay({ type }) { const map = { sunny: , rainy: , cloudy: }; return (
{map[type] || null}
); } WeatherDisplay.propTypes = { type: PropTypes.oneOf(["sunny", "rainy", "cloudy"]) };