PRA#03_React-AntoniCarrascoVilar-WeatherApp - #6
Open
Antonicv wants to merge 13 commits into
Open
Conversation
…for better aesthetics
…nates and update localization strings
…oved responsiveness and error handling
…, and replace favicon
… entry point, and related assets
…ns, and hooks explanation
…chnologies, project structure, hooks explanation, usage instructions, and contribution guidelines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Weather App
This Weather App provides real-time weather information and forecasts for any city. It also includes an interactive map to explore different locations. The app is built using React, Material-UI, and various other libraries.
Table of Contents
Features
Technologies Used
Setup and Installation
Clone the repository:
git clone https://github.com/your-username/weather-app.git cd weather-appInstall dependencies:
Create a
.envfile in the root directory and add your OpenWeatherMap API key:Start the development server:
How It Works
Weather Component
The
Weathercomponent fetches and displays the current weather and 5-day forecast for a specified city. It uses the OpenWeatherMap API to get the weather data.Map Component
The
MapViewcomponent displays an interactive map using React-Leaflet. Users can search for cities, and the map will center on the searched location.Theme Context
The
ThemeContextprovides light and dark theme modes. Users can toggle between themes, and the preference is saved inlocalStorage.Hooks Explained
useState
The
useStatehook is used to manage state in functional components. It returns an array with two elements: the current state value and a function to update it.Example:
In the
Weathercomponent,useStateis used to manage the state for the city, weather data, forecast data, loading state, error messages, and the selected tab index.useEffect
The
useEffecthook allows you to perform side effects in functional components. It takes a function and an optional array of dependencies. The function runs after the component renders and whenever the dependencies change.Example:
In the
Weathercomponent,useEffectis used to fetch weather data when the component mounts.useContext
The
useContexthook is used to access the context value in functional components. It takes a context object and returns the current context value.Example:
In the
Layoutcomponent,useContextis used to access the theme context and apply the selected theme to the application.useTranslation
The
useTranslationhook is used to access translation functions and the current language in functional components.Example:
In the
Weathercomponent,useTranslationis used to get the translation functiontfor translating text based on the current language.useMap
The
useMaphook is used to access the Leaflet map instance in functional components.Example:
In the
MapUpdatercomponent,useMapis used to get the map instance and update its center when the coordinates change.Libraries Used