|
How I created Weather App using React JS

How I created Weather App using React JS

September 29, 2024

This guide provides a comprehensive step-by-step process of how I created a Weather app using React. It covers everything from setting up the environment, installing necessary dependencies, and structuring the project to managing state with callbacks/hooks, integrating Open Weather Map’s API for fetching current weather data and implementing user authentication.

Steps:

  1. Begin by installing Node.js on your system. Then, open Visual Studio Code and create a React app using the npx create-react-app command in the terminal. This will initialize your React project structure.

  2. Download and install all the necessary libraries, including Styled Components for styling, Axios for API requests, and React Icons for incorporating icons into the UI.

  3. Inside the index.js file, mount your main App component and render it with the root element of your project.

  4. Set up an environment variable that will handle storing your API key. It will be used to retrieve weather data from openweathermap.org.

  5. Make a SearchCity component that will handle searching for cities. Add an input field and button, and update the search path. Implement a function to handle input changes and request the necessary API calls. The component should return a form that lets users input which city they want to check.

  6. Add another component for displaying the fetched weather data. The data will be fetched using Axios and stored in state.

  7. Use Styled Components to add styling across all your components. This will keep the overall user interface and experience consistent.

  8. Link to Weather App: https://weather.devibbi.com/

  9. Link to my Profile: https://devibbi.com/