A React-based web application that allows users to search for and view current weather information for a specific city. It fetches weather data from the OpenWeatherMap API and displays relevant details such as the city name, temperature, climate, and an icon representing the current weather conditions.
- User input field to enter a city name
- Fetches weather data from the OpenWeatherMap API based on the entered city
- Displays the city name, temperature, climate, and an icon representing the current weather conditions
- Shows the current date and time, updating every second
- Handles loading and error states during the API request
- Responsive design for optimal viewing experience on different devices
- React
- React Hooks (useState, useEffect)
- OpenWeatherMap API
- react-icons library
- Node.js (>=14.0.0)
- npm or yarn
-
Clone the repository:
git clone https://github.com/your-username/weather.git
-
Navigate to the project directory:
cd weather -
Install the dependencies:
npm install
or
yarn install
-
Create a
.envfile in the root directory and add your OpenWeatherMap API key:REACT_APP_API_KEY=your_openweathermap_api_key
-
Start the development server:
npm start
or
yarn start
-
Open your browser and navigate to
http://localhost:3000to see the application in action.
- Enter the name of a city in the input field.
- Click the "Go" button to fetch the weather data for the entered city.
- The app will display the current weather information, including the city name, temperature, climate, and an icon representing the weather conditions.
- The current date and time will be displayed and updated every second.
src/components/WeatherInput.jsxWeatherStatus.jsxWeatherInfo.jsx
image/...
App.jsindex.jsstyles.cssWeatherApp.jsx
- WeatherApp: The main component that manages the state and contains the logic for fetching the weather data.
- WeatherInput: A component for the input field and button.
- WeatherStatus: A component for displaying loading and error messages.
- WeatherInfo: A component for displaying the weather information.
- OpenWeatherMap
- React Icons
- Weather App by Ali Turkaman
