Podcast Lookup

Build a Weather App with React JS and Redux | Practical React Redux Project

ReactJS Developers Podcast

  • December 3, 2026
  • 1 h 35 min
  • Episode 29
Episode page
About this episodeWant to strengthen your React Redux skills by building a practical application? In this episode, you'll learn how to create a Weather…
Want to strengthen your React Redux skills by building a practical application? In this episode, you'll learn how to create a Weather Application using React JS and Redux.This project demonstrates how Redux can help manage application state while building an interactive application that retrieves and displays weather information.You'll explore how to organise your React components, manage shared application data, handle user input, and integrate weather information into your application.By the end of this tutorial, you'll have a better understanding of how React and Redux work together to build dynamic applications that interact with external APIs.What You'll Learn
  • How to set up a React JS project.

  • Understanding Redux and its role in state management.

  • Integrating Redux into a React application.

  • Creating reusable weather application components.

  • Managing application state with Redux.

  • Handling user input for searching weather information.

  • Integrating a weather API to retrieve real-time data.

  • Displaying weather details dynamically.

  • Handling loading states and API errors.

  • Updating the interface based on Redux state changes.

  • Organising and structuring a practical React Redux project.

Who Should Watch?
  • React JS beginners and intermediate developers.

  • Developers learning Redux and global state management.

  • Frontend developers interested in API integration.

  • Students building practical React portfolio projects.

  • JavaScript developers looking to improve their application development skills.

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

Build a Weather App with React JS and Redux | Practical React Redux Project

00:00—
  1. Speaker 1

    Now we are going to make a very beautiful application and it is such a beautiful application that it can be completed in 7-8 minutes. But this is not our major goal right now. Our major goal is to learn state management. Right now we are running a series of state management in React in which we have properly discussed state management, context API and then just stand and then we made a project. We have discussed Redux and now we are going to make a project based on Redux. Exactly Redux I am introducing in this. Introduce has already been done. We are going to see proper implementation on real world project. Because until you do that, it won't be fun. So it's a small project. You can make it without Redux also very easily. And I also agree with this. But here you will learn the proper implementation of Redux. And how asynchronous programming can be done here. Because asynchronous tasks are going to be done here. So you will know how to implement it in Redux. So you will get one extra thing. And that will be our main focus here. So our project is a simple weather dashboard as you can see. And you can search any city here. So by default, Delhi is there, so I search. So our weather comes here related to this. Along with that, your forecast comes here of 4 days. That is, how the weather will be for the next 4 days. Like today is 15, so the weather of 15 is visible here. Along with that, you will also see the weather of the next 4 days. 16, 17... 18 and then 19 and then last here you can see 20. So in some way, you can see a forecast of 4 days here. But that is also not important, they will call the API, we will get it. Our major goal here is state management. That whatever is written here, if I write Bhagalpur here, then it should be linked properly with the whole project. It is possible that you want to use this state somewhere else. So, how will you link it? For that, we are going to use State Management Library Redux, which you saw in the previous lecture. So, as soon as I write and search in Bhagalpur, then here you have the details of weather related to it. Along with that, the details of forecast have come here. So, there is only one city, there is only one state, we are using it in both the components. One is in this component, which is the weather component, the current weather component. And here in the forecast component also, we are using the same state. So, multiple places, same state, and you can take it to a higher level as well. We have done state management in this way. We have done proper setup in this way that you can take this project to a higher level as well. And whatever projects we will do in the future, we will do something in this way. Although, we will work on Redux Toolkit. But, whatever things you will learn here, it is the same. Redux Toolkit is also based on Redux. Isn't it? So, let's quickly start this project. And before that, I will tell you I will say the same thing again, if you watch the previous lectures, it will be fun. And also watch the Redux one. Otherwise, there is no point in making a project. I am not teaching you Redux here. In Redux, an extra functionality, an extra middleware is our main focus here, which I am going to tell you, that is Thunk. So that you can do asynchronous programming. Rest, the proper setup of Redux and all the things that happen, along with how to connect DevTools etc., And how can you do persist? I had told you all that in the previous lecture. It's a video of around 1 hour and 10 minutes. So, everything is in it. You have to watch that. And then watch this after that. Otherwise, it won't be fun at all. And keep coding along with it. If you watch it like a movie, then it won't be fun at all. So, this is your project. This is me. And you are sitting. Come on, let's quickly start our project. So I have opened my VS Code, you also do it quickly. And this is our React folder, where I am organizing all my code as always. And we have done so many things, some projects will also be in it. And you will get all the code in the description. Basically, you will get its link in the description, you can check it out. You don't have to worry about the code, you just have to learn it well. And first of all, we have to set up a new project, so for that I will come to the browser. And here I will open a new tab and search. tailwind css this will install tailwind and weed and we are going to use daisy ui if you don't have idea of daisy ui then also don't worry you don't have to go to previous lectures to see daisy ui although we have discussed daisy ui in a news application but again if you don't know then you don't have to see it separately you will be clear in this so here the setup as I am doing all these things are already coming to you we have done in many lectures so here you have to press command paste, and here you can change the name if you want, I give the name here, Redux Project, and along with that, here also you have to give the same name, Redux Project, spelling mistake, project, okay, so here I gave the name Redux Project, and with CD Redux Project, we will jump inside that folder, and start our work, so it will also be installed, and it will also go inside that project, So package name Redux project is to be kept. And here we have to use React. Definitely we have to use JavaScript. Alright. And experimental no. Start. No, we don't have to start now. So this is our Redux project. See here it has come. And this proper folder structure has come. And we have come inside Redux project. By doing CD Redux project. And here I will clear. The command which is here. I will paste it here. And enter and install it. And it is also saying that you can copy and paste this one here in vid.config.ts. So we will not have ts, it will be js because we are using js. We have not done ts yet. So here you have to plug it in like this. And all the things are mentioned here, so you don't have to worry separately. Okay. So here I have done what I have done and here in index.css You have to paste it. The main CSS file has to be pasted there. So our main CSS file was index.css. I have pasted it here. And I will remove the entire app.css from here. Okay. So this is our Tailwind setup. Now let's come to DAISY UI. And let's quickly set up DAISY UI too. DAISY UI. In this you will get made-to-be-made components. There is nothing else special. You will get made-to-be-made components. The code is made-to-be-made. It is based on Tailwind. So it is important to install Tailwind first. Then you will do DAISY UI. And you will get made-to-be-made components. You can use it directly. There is no need to write css or tailwind, you will get the components made and you will enjoy it. So come to daisy UI, click on how to use or you can open the documentation. So here it will tell you how to install as a dev dependency, so without understanding, you can install it for now. If you know dev dependency, it is used only during development, so our daisy UI is the same. And here, the tailwind CSS configuration we did, just below that, you have to attach this plugin. In index.css, this tailwind CSS we had imported, just below that, you have to attach this. And our work is done. Really? Exactly, our work is done. And in app.jsx, you remove all these useless codes. We will clean all the useless, dirty codes here. Oh man, get clean quickly. This is done. This is done. Remove the assets folder from here. Remove this strict mode in main.jsx. And very good. Now we can run it using npm run dev. And this is our run project. Okay. And we will keep this daisy UI open. Because from here we will search components and do our work. So here you see daisy UI and version is also written. That means our proper way of daisy UI is set up. And daisy UI is set up. That means tailwind is also set up properly. So, now we can work here. What to do first? First of all, I will do state management here. Because UI-wise, there is nothing here. If you see design, then design is very simple. I have not focused on it. So, the main work we have to do is state management work. So, we will start with state management. Previous lecture was of Redux. You see and then continue from here. First of all, you have to create a store. You have to give the name of the folder in which you will manage all the things like store, access and reducers. Or you can also give its name as store. So I will give its name as store. And in store, we will do all the setup of Redux. First of all, we will create a store file, store.js. And here I will minimize it. I will minimize it and zoom it so that you can see it properly. We will import here. Create store from redux and we haven't installed redux so install redux quickly npm i redux and also react redux for connection you know all this already so these two things you have to install redux and also react redux so if you have installed this well and good and I will cut it and this is running our project so I will minimize it again and this is done So we have Redux, we will use it to create a store. So const store is equal to createStore. This is our store and we will do export default store. We haven't done the proper configuration in the store yet. We will do everything. But now we have an empty store in which there is nothing. That store is ready. to be made. Our second task is to provide that in all the components, we will be able to use its actions or its states. So we have to provide. To provide, we will come to main.jsx. And here we will use the provider. Import. Where will the provider come from? What do we use to make connections? Tell me quickly. You have seen this in the previous lecture. To connect Redux to React, we use React-Redux. So for connection, we have to use React-Redux. Okay. With this, you will get provider. And with this provider, you will wrap your application. Provider. And here, you will link your store. See, your store will be imported. And see carefully, whether the import is done from the right place or not. That means, the store we made in the store folder, whether it was imported from there or not. So, our import has been done from the proper place. So, we brought the provider. We put the provider here. And we connected our store in it. So, we put our store props in it. Our store is properly linked to the React application. That means, we connected Redux to React. This much work is done. Now, let's move ahead. Now, we have to do all the other work in the store. So, first of all, we have to make a reducer. So, for reducer, I will make a folder here. Reducers. and here it can be multiple reducers, I am going to make only one reducer, it will work, it is a small application, I will make one, it will work, after that if you want to increase it, you can make multiple reducers in the same way, so here first of all I give its name, weather reducer.js, ok, we are going to make this weather reducer here, what is a reducer, you have a good idea, nothing different, it is a simple function, something like this, const, and I will name it as weatherReducer. And this is a simple function. Why am I calling it a reducer? Because you will connect it to the store. After connecting it to the store, you will get some extra features. First of all, we will export it. Let's do one more thing. Let's do the export like this. Named export. And here we will put the reducer. Which reducer? WeatherReducer. Okay? So, we have added this. Now, as soon as we connected WeatherReducer with our store, that means we connected it with Redux. Now, here we don't have any normal function. This is our reducer, in which you will get two things, which I had told you. Quickly tell me what things you will get here. So, state you will get first. Second, you will get action. State and action. This function of yours, which we are calling reducer, in which you have two things, state and action. Okay? Now on the basis of state, we will make changes in the state, so all the places will be reflected and on the basis of the type of action, we will work here. So first of all, make the initial state, const initial state and I am moving forward fast because we have already discussed all these things. So here in the initial state, think about what you have to do. So in the initial state, what I am feeling right now, first of all, you will have current weather details here, which is null by default. After that, you will get details related to the forecast. And we don't have details related to the forecast. Then loading. Here we will make a state which is by default false. As soon as we send the request, we will call the API, the loading will be true. And after the data comes, we will make the loading false again. So this is what we have made for loading. Then let's make one for error. By default error is nothing, it is null. If error comes, then we will save error in this state and render error on our UI. Something went wrong. You must have seen this way before. and city is the most important here city should be there so here city will come to you on which city basis you want to search basically so by default I will give this city to you here Delhi ok so this is our initial state in which you have total 5 key value pairs city, current, forecast, loading, error current you are understanding for weather and the weather details you will have how much degree celsius Then forecast, 4 days of future. And then loading, you understood that loading state, as soon as you send request, it will be true. So, loader will be seen on your application. And then as soon as data will come, it will be false. Error, if something comes, then we will show. Otherwise, it will be null. And here you have city, Delhi, on whatever basis you want to search, Delhi, Bhagalpur, Noida, wherever you want to search weather, it will be coming here. Okay. So, we will pass this initial state here in state. So, you got access to state. Did you get it? Tell me quickly. Yes, you got it. You got the state axis. So, in this state, we will be changing using reducer. So, through reducer, we will change in state. And as it changes in state, all the places will be reflected. So, you know all these things. Now, here, we don't have action. So, we will make action. And action is a pure object in which you have type. And what do you have? It is payload. Action is a pure object in which type is payload. So, I am assuming that you already have some types. is available. For example, I am using if else condition here. You will see switch case in many places. So, I am here. Action.type if we have here. First of all, I will define all the types. Later, I will make action. Okay. So, here if action.type and I told you that if you make constant and use it, then it is better. Here multiple types can be there. First of all, it can be that fetch we are doing is in pending status. Okay. First of all, you understand this here. if you don't have any idea about this, then you can understand here that whatever API we will call, whatever API we will call, here in API call, you will have three statuses. The first status will be pending status. That means you haven't just called API, you are just going to do it. So pending status, means you are initiating right now. So at that time you can set some states, like loading true, you are going to hit API, you have to make loading true. After that, you have two more statuses, either success or error. Meaning, you can get data if you get success, or you can get error. So if you get success, then also you have to make changes in the status, that means you have to set the details of the current data or forecast, and also you have to make the loading false. So success or error, you have to make the loading false. and if it is in pending status then loading is TRUE that means you are about to hit the API so loading is TRUE and as soon as success or error comes then loading is FALSE and if success happens then you have to set the details and if error comes then we will set the error so there will be three statuses so in action we have three types here that the weather that we are fetching is in pending status then the success status of weather fetching, then the error status of weather fetching. And along with that, I will make one for forecast. And for forecast, you can make these three separately. But I will not make three separately, I will do it in one. In what way, I will show you here. Now here, the type, for type, I had told you that if you define some constants, then it is better. Because you will use the same constant in reducer too. And you will use the same constant in action too. You are remembering, right? What I want to remind you. You have seen the previous lecture, right? Very good. So here, we will not make a constant in reducer. We will make a different folder for constants. constants. And here, veder constants. Veder constants dot js. So first of all, we will make a constant like this in capital letter. Veder fetch veder pending. This is our pending status. And this same to same you have I will put it in string. Basically in value. So this is your variable and in variable you have this string. So in the same way I will make a lot of things for you. So let's export this too. And I hide this for a little while here. And in this way we have 4-5. First of all fetch weather pending is done here. And here fetch um we have two things, current weather, pending is our or we are initiating, then after that we may have the current weather, current weather details, we got its success, we got the data, or for forecast, see you can make it different for both, like I am making it for current, current weather details, means whatever 24 degrees Celsius, 27 degrees Celsius, now current details, so for current details, the API you are calling, you will also have three statuses, pending, success, error, And then for the forecast, you will also have three statuses. Forecast pending, forecast success, and forecast error. So you can make it different. I will show the forecast and current in one success. Rest, I will make it different for pending and error. Okay. I will tell you. I will tell you right now. So fetch, weather pending, current success, and then our forecast success. And here weather error happened. error and here you had success success now I will explain all these things so this is done and one will be our another action to set city set city ok so we will have only one action set city fetch weather error fetch weather pending ok fetch current success fetch forecast success Now look carefully, I will use success for current and success for forecast at the same place. And this will work for both pending. for current and error for current. You should have made pending status for forecast and error for forecast. so that loading is true for both and if its data is loaded then loading will be false and if its data is loaded then loading will be false so we had to make it different but I made the pending status the same for both if we initiate then we will use both together and if success comes then if any one of them gets success then we will show the data by doing loading false and if there is an error in any one of them then we will use the same action and set the error there is an error in any one that means we will do both in one API call both API will call together using only one action. So that's why I finished it in one. I made the same for both the pending and the same for both the error. You should do it separately. And this is your homework that you will do it separately. Homework or self-tax, whatever you want to believe. Assignment is for you, you will do it yourself. Okay, so in this way we are going to work here. And here we have made a reducer. So type, now you know what type you have. The first type you have is fetchWeatherPending. And I have exported it here. See if I have exported it or not. These were our constants. And I have exported it. No problem. Here you are not getting suggestions. So I will manually import it here first. Import import from dot slash dot dot slash constants and weather constants. So now you are getting suggestions here. Fetch weather pending. So if pending status is there, So we are going to do some work here. And if else if action.type is our patch weather success. Not patch weather, our current success was for success. Alright. Else if if action.type is our patch forecast success. And else if action.type is our patch Forcast success. And what else did we make? Remember quickly. Pending happened. Forcast happened. Current happened for error. Fetch error. Weather error. This happened. And we had some type. And one was to set city. Else if action dot type is set city. So we will do some different work. And in default case we will return the whole state. This is very important. Return the state as it is. we will return this state as it is in the default case otherwise it will be undefined in the state if we don't return it, then it will be set as undefined in the state now in the different cases we will do some changes with the state like if you have pending status, then I have told you that whenever it is in pending status that means we are going to start calling the API So what are the things you want to set up before starting? So you will want that as soon as the API call hits, your loading will be true before that. So here in the loading state, we will make a splash. Along with that, if you have any previous error, present, any API call is already done, error has come, then we will empty that error. So loading will be true, error will be empty, null will be done. And in city, current and forecast, we don't have to make a splash. In pending status, we don't have to make a splash in it. So what are we going to do here? return and apply curly braces like this see here we are returning the object so dot dot dot state we have spread the whole state that means we don't have to interfere in everything we just have to interfere in loading so I will make loading true here and I will null the error in pending we have to do the same thing null the error so when we will hit the API before that I have set up all this loading is true loading is visible and error is null Now you have two things, if you have current details and forecast details, then you will have success status in both. There were only three statuses, pending, success and error. I have not made pending different for both, both will work in the same, error will also be in one. Both are different for success. So what to do in success, think carefully, if you have current details, current weather details, save it in current key and loading is false otherwise it will keep loading and what we have to do? we don't have to do anything in error we will handle error in error first let's do error return we don't have to do much in error, we have to keep the state as it is, we have to make the loading false, we have to make it false, whether the data comes or not, if there is any error, then we have to make the loading false, if there is an error, then we will make the loading false and show the error, so here in the error variable, we will put action.payload, I told you that you have two things in action, type, on the basis of type, we are checking what to do, and in that action, we can also send payload, that means we can send some data, If error comes, then we will send error related data. We will see how to do all these things. Even though I have explained in detail. Xn.payload will come here. Error will come and we will set it in error. Our error work is also done. After that, if current data comes to you, then we will set it in current. And if forecast related data comes, then we will set it in forecast. That's it. That's it. It's so simple. Return dot dot dot state. And we have to false the loading. Okay. And error, error, error, etc. Nothing. Data has to be set here. Current one. In current, you have payload dot, sorry, action dot payload. Action dot payload. So, in action dot payload, our data will be coming. We will set that here. Okay. Then, if success happens, then return. If success happens in forecast, then state. And loading, again, we will false here. If any of the two is successful, then we will false loading. Because we are using the same for both. you could have made it different, like if current is successful, then do current loading false, if forecast is successful, then do forecast loading false, but for that, I have to make pending status different for both, and error for both, so I made it the same, and here, not current, you have to set details related to forecast, so action. payload, okay, your work is done, very good, good, So, we have done almost everything. We have not done the city work, so the city work is simple. We don't have to do much in the city. There is no asynchronous work in the city. As you type in the city, you have to set the details here. So, you just have to set the city here. Action dot payload. So, see there is only one reducer here. Your work is done with only one reducer. It will do it on action. If the action type is fetch weather pending, then we will set all these things here. If action type is fetch current success, then you have to send current weather details in payload. And if action.type is forecast success, then you have to send forecast related data. And if error has come, then you have to send error in action.payload. So it depends on action type and payload. You have to send payload according to type. type is success, so send error in payload and in city we will set city and that's it. Reducer is complete. Now you must be thinking that you are not seeing anything. If you set up in states, then the process of state management is long. Okay. Whether you take Redux or not. Redux is very long. If you take Redux toolkit, then first you will set up properly. Then at the end you will see the result that whether it is working or not. It is not like that you are doing small small work. So a lot of time passes in it. So once you set up properly here. And then after that you will see whether it is working or not. So our reducer is made. Now our work is just to make action. We will make action and that's it. Done. Okay. So let's make action now. So, new folder, actions, and in actions, we have the first one, whether action.js. Okay? So, what is action? It's a normal function. You said it's a plain JavaScript object. Yes, it's an object. It's a return object. It's a function. Okay. It's a function, but it's a return object. The type and payload, etc. Okay. So, const, First of all, which action will come to you? So in the sequence, the five ways we saw, the five types we saw, we have to make five actions related to them. So let's make it. Fetch weather pending. So this will be one action you have. In the same way, multiple actions will be made and also export. And here, import constants first. Import from dot dot slash. So, if it is pending, then return an object as I told you. Action is nothing but a plain JavaScript object. So, type will be fetchWeatherPending. If you will send type, then what payload you have to send payload you don't have to send anything pay attention again go back to reducer and see if type you have fetch weather pending then payload you don't have to use here just do loading true and do error null that's it payload you don't have to send anything that means we don't have to pass details alright then in the same way more will be made so here I will copy paste it to make 5 so one is done we have fetch weather pending after that we will get here Fetch current success. This is written like this. Fetch weather success. Okay. And here you will get fetch weather success. That variable was ours. Weather success was fetch current success. Fetch current success. So here also instead of weather you do current. Current. or you can write weather as well whether you want weather related details or weather forecast related details but current and forecast are also fine so you can give the name of the variable as per your choice as you like fetch forecast will come here and here also fetch forecast success alright and here fetch fetch weather error and here instead of fetch weather pending you will get error and here not pending you will get success success name a little consistency maintain so you will like it and here you will get set city action set city now see the payload in which you have to send in this you didn't have to send ok If the current data is successful, then pass the data as it is. If it is successful, then you will definitely get some data. So take that data and pass it as it is in the payload. I have passed the data. So this is also successful. If the forecast is successful, then the data related to the forecast will come. So pass the data as it is in the payload. So this is also successful. After that, we have fetchWeatherError. In error, you will get some error. That error, as it is, pass in payload. Very good. After that, what will happen to you? In CT, you will get some CT. So whatever CT will come, pass it in payload as it is. Our work is done. All the action is also done. Now see this. Okay. If we have pending status, then we will call this action, it will work. If we have success status, then we will call this one, it will work. If we have got success in forecast related details, then we will call this action, we will send data, it will work. If error comes, then we will call this function, basically we will call action, we will send error, it will work. Okay, so as soon as we dispatch action, it will match with reducer, it will match type, after matching type, whatever work we have done in it, we have done in states, it will do its work. So, now we have to trust that it is on action. We don't have to look at the reducer. However, if we see some bugs, then rest of our work is based on action. We will trigger action. If it is successful, then we will trigger action and send data. And we will hope that our work will be done. That's it. Very good. So, we have made all the actions. Okay. Now, answer me one question. When you call API, it doesn't happen that you call API and you separate it. Success API is separate. Error API is separate. No. You call only one API. You have three possibilities in it. As I just told you, if you call one API, first of all, it will be in pending status. Then, if API call is done properly, then you will get success status. And if something goes wrong, then you will get error. So, we have to make a function in which we will only call API. So, let's make that one here. Set city just below. Export const fetchWeather. And only we will dispatch this fetchWeather action and our work will be done. How? These are all statuses basically. Pending status, success status and then error status. So, these are all statuses of yours. Actually, they are not doing the work of fetching. They are just doing the work of making noise in states. So, who will do the work of fetching actually? Actually, the work of fetching will do the function of fetchWeather. Alright. So, what will the work of fetchWeather do? First of all, bring the API. If you bring the API, then only you will work. So, here you search for OpenWeather. OpenWeather. And you find the API of OpenWeather. How will you find it? So, you have to log in. I have already logged in. So, you can go and log in. If your account is not ready, then create an account. And you get all these things. You can create an account. Create an account and as soon as you come to your account, you will see my API keys. So, copy the API keys carefully first. This is very important. Okay, mine is also logged out. It looks like it is logged out, but my password is saved. So, I will log in again. So, login is done. And here I will go to my API keys. So, here is my API key. So now you have seen the API, but don't use my API, there is no use. It's not like I have taken a subscription of OpenWeather, so you will get some paid things, it's not like that. It's free, I am also using the free one. So if you use more, then the limit will be over, you will not be able to work. So it's better to remove your API from here. Come here, make an account and take your API key. You can try it with my API, but I don't think it will work. If maximum people do it, the limit will be over immediately because I have not bought the plan. So here I told you the best way to store the API key. What is the secure way? That is in your root folder. See this is your root folder. So in this root folder, not in the SRC, in the root folder, in the root folder, you will make your. env variable here. where your wheat.config.js is, where packet.json is, there your env should be made. And in env file, key value, key value, yes, you can say key value, basically there is a way to make variables. In this, you have to put a prefix like this, wheat. It is important to put a wheat prefix. And after that, you can give the name of your variable, like my weather API. So this is our variable. In the future, it is important to put this wheat prefix, otherwise it will not work for you. so we have to use the prefix wheat because we are using wheat in the previous version we used to use create react app so you can search on the documentation if you have forgotten so I remember that wheat is used in the prefix so I have added my API here so how will we use the API so I will tell you how to use it, for now you have come to the API Now come to the API tab and see which API you want to use. I can see the current weather data API here. I will click on the API documentation and see you have this API here. So you have to use this API here. Where? Here. So what will you use? Will you use Fetch or Axios? So I will use Axios. And you can make an instance here. As I told you in the news application that you should make an instance and work. But this is not our lecture. This is our Redux lecture, so I won't do much work here. I will directly get Axios here, our work will be done. So Axios equal to, I had given, in Axios I will call this API and that's it. And Axios will also have to be installed, so I will do it quickly. NPM I Axios. So it won't take much time, it will be installed quickly. It has been installed. Alright. Const response we will get in return. and also import the axios otherwise you will get an error import axios from axios so our axios is imported I have used axios and here we are fetching the weather like this and we don't have to fetch the weather according to latitude and longitude ok here we have to pass the query and in the query we have to pass the city ok so first of all we have to give the API key here so now you can order the API key here how will you order? so for that you have to import. meta. env. the same variable that you made here. This. Okay. So from here your API key will come. Okay. And carefully I am saying it again and again in the VIT prefix. You have used this. Then your import.meta.env and after that the variable you are passing will work. So save it in a variable. Const API key. API key. Okay. This will be your API key. And I will pass this API key here. Okay, now we don't have to use the template literal, so we have to do that. In this way, we will remove the normal string and use the template literal. We will put dollar here. And this API key is already added. Okay. And what is here? https colon slash slash api dot openweather dot map dot org slash data 2.5 weather. After question mark, this latitude longitude is attached. We don't have to work on the basis of latitude longitude. We have to put a simple query here. So for query, query is like this. Query is equal to, you can insert your query here. In many places, it is only Q. So here it is only Q. You have to read the documentation, how they have given the query here, whether they have told or not. As far as I am concerned, I have not searched the query. you will have to see here, I saw it here somewhere, you can search, so I told you, in this way, you will put a query here, query is equal to, and here you can pass your query, whatever city basis you want to search, or whatever basis you want to search, query also means, that you can put your query here, and search, okay, So I have passed the city here. Now read the documentation properly. This way your work will be done. You do it yourself, your work will be done. So I put the city here. Alright. So what will this do? Okay, where will the city come from? So city we definitely have to take from here. Fetch weather. We have to take from here or we can take from state too. And from state, no, we will take from here. Actually, when we will do fetch weather, then we will pass city here and city will come here. So, first of all, let's see if we are getting the response or not. Now, if we want to call this function, then the function can be called in a normal way, but again, we are using Redux, and on the basis of Redux, we want it to work by connecting with Reducer. So, we have to dispatch this function here, or you can call this action. So, we will come to app.jsx, let's do this work in app.jsx. So, use dispatch, you have one, First of all, we have to import hook from redux or react-redux. So the state management work is done, now the work to connect is done. So here react-redux, we have to call the action basically. So here we will have use dispatch and we will use something like this, font-dispatch is equal to use-dispatch, like we use hook, navigate etc. So we have to dispatch this dispatch. So for now, let's put a use effect here. So what to do, nothing else to do. So we will dispatch here and in dispatch, we have exported the fetch weather. So we will call fetch weather here. And while calling fetch weather, we have to pass the city. So pass the city carefully. For now, I will give the city as Noida. Pass the city and see that our weather is not fetching. And I have written the spelling of response wrong. And very good. Okay, one more thing. You can't actually call API here. Redux is completely synchronous. Redux is completely synchronous. Asynchronous can't work here. So the dispatch I have done, let's see if it is working or not. So I have dispatched it, I will come here in my application, I will reload it with Ctrl Shift I. So actions must be a plain object, instead the actual type was undefined. Where is this error coming from? Redux thunk, see here it is asking to set up thunk, this is the error coming from it. I hope so. So I will comment this and after coming to app.jsx, I will comment this too and see if our error has disappeared or not. so error has gone, the requested module does not provide name export default, it is coming because of this, let's comment it too, so our error has gone completely, that means everything is fine, we can't do it in this way, we can't call API directly here, Redux is synchronous in a complete way, so how to make it asynchronous, because we have to call API, and all those things are asynchronous, so how will we do that, So for this, you have to set up thunk here and it is also saying that you have to set up thunk. See this, here you have to set up redux thunk. So redux thunk is your middleware. So first of all, you have to install redux thunk here. npm i redux thunk. So we will install this. As I told you redux persist, in the same way you have to install redux thunk here. And I close it. Now the redux thunk that you have installed, you will import it here. Import from Redux Thunk. And you will get a thunk from Redux Thunk. Now you have to set this thunk as a middleware. Now if you want to set middleware, then for middleware, you have another parameter here, Apply Middleware. But I don't just want to set a middleware, I also want access to DevTool here. Chrome extension, I had installed DevTool, so I have to connect DevTool too. So I want to install both DevTool and Middleware here, so I will use Compose here, and I can use both together now. So, I will use this compose and compose, see, you have Redux imported. Okay, now inside this, I can also apply middleware and at the same time, I can also put a dev tool here. So, let's put a dev tool quickly. So, the command of dev tool is not remembered. How to connect Redux dev tool. Search it. How to connect Redux dev tool to Redux. Here you search. In stack overflow, you will get this command completely. See, this is the command. Copy all the commands and cut it. OpenWeather, etc. is fine. Paste it here. Is it not copied properly? Oh, man. It's wrong. So, we will copy it. And I will paste it here. And let's save it in a variable. So, const redux devtools. And I will apply this redux devtool here. So, apply middleware is a function like this. And here you will pass thunk like this. So, this is your middleware setup. You applied apply middleware. Which middleware did you apply? You applied thunk middleware. And along with that, you also connected Redux DevTool. So, now you will enjoy. These two things that we have done. These two things that we have done. We have done a very good job. Okay, still this object is coming. It is saying that we have set up ReduxThunk, that error is gone. But here we have to do one more thing. See, we are using it as a normal function, like a normal action. We don't have to work like a normal action here. Now here you have to make it asynchronous. So to make it asynchronous, you can't directly put an async await here. You have to return a separate function here. This is syntax. You have to return a separate function. Now you can make this function you are returning asynchronous. Okay. So, there was a slight change in the syntax that we will return a function and we can make that function asynchronous. However, there is one more special thing, here you get a by default dispatch, which you were getting as a hook here. It is also available here because you know that we are calling the same API. Basically, we will dispatch the same action here and multiple actions will be dispatched in the same action. In the same action, You will also have pending status, success and error. How to dispatch them? By default, you get a parameter here. The function you just made. As soon as you set up the middleware, you get a function. Asynchronous function. And in that function, by default, you get a dispatch parameter. With that, you can dispatch all these actions extra. Alright. Free syntax. This is how your syntax is. And now you come here and see, you have an error coming, it has disappeared. So the error has disappeared. And this promise is coming because we have not awaited here. We have awaited and congratulations, our data has come. So the setup was a bit complex. I totally agree with this thing, the setup. Actually, it is very complex to set up the thunk and etc. But once you have tolerated it, then the Redux Toolkit that we will do, you will say, man, this Redux Toolkit was so easy. So, you will believe yourself that, okay, yes, that's why Redux Toolkit was designed. Actually, it is very simple. So much middleware setup and so many actions, constants, etc. etc. we make, you don't need to do all that. So after this, the next lecture is going to come on Redux Toolkit. So if you are doing all these things and reaching there, believe me, it will be fun. It is possible that you do not understand everything here at once. You have seen the lecture on Redux, you are doing the project too, you are doing it by watching it together. It will not be clear to you in one go, but at least once you have done the go through, Redux Toolkit will be clear to you in a very proper way. And you have to do it in the Redux Toolkit. If you get the old legacy code bases, then you will understand how to do it. Rest, when you get it, you can repeat the lectures or read the Google documentation and things will be clear to you. So, if you can understand my goal, why am I telling you all this? It will be useful if you go to companies. So I reloaded it and the data is coming to you. We have done a very good API call. In the same way, we will also do it for forecast. So for forecast, you don't need much. If you want, you can search. For forecast, you have hourly forecast available. But it is included in the developer professional and expert subscription plan. At least you have to take a plan. And this current weather one was free. You get it for free and with paid subscription. It depends on how much heat you want. How much API you want to call. So this was free, but it is paid, so it will not work. But I know a way to work, which I will tell you. See here, they have done this. Copy it. We have to call a separate API for the forecast. So they have worked on this whole thing. First of all, put this dollar here. And here you have the API key. Okay, we don't need latitude and longitude. Remove this. And you have to put a query, but not on an hourly basis. Okay, remove this hourly one. The rest is free. This forecast, as it was here, weather. Question mark query you had put here. Forecast question mark. And here you put query in this way. That's it. And do response 1, response 2. Or call it current weather details. And here forecast details. Forecast details. Okay. Okay. Current weather details and forecast details. All right. So here you are getting details related to the forecast. And what will you give in the query? You will give again city. So here carefully give the forecast question mark query. And the rest will be coming here as API. Okay. So you can see both here. Current weather details. And along with that you will be fetching forecast details. Both will be fetched as far as I think. No problem should come here. I reload. So here you can see. This data is coming to you. Data related to weather. You can see data. You have a lot of things. In the main, you have temperature, humidity, pressure, and temperature as well. It is given in Kelvin. I believe it is in 285 Kelvin. So, you can convert it to Celsius by doing minus 273. You have read all this in your childhood. Okay. And here you have data. And here you have a list. See, this list is important. Here in the list, you are getting future forecasts. So you can list all of this. Here you can see the date. We will list the date and also the temperature. That's it. Our work will be done. So the data has come to us. Okay, now we have not done this work. We have created different actions for status. If it is pending, then we will do this. If it is successful, then we will do this. If it is forecast, then we will do this. and if there is an error in the weather, then we will do this. So we have to do that, because now see the data has come to us, but we have not set the data in the state by dispatching it through actions. So until we set it in the state, we will not be able to use it in the rest of the place. Now if you see the state, then the state will be empty. Here you use the useSelector, const state is equal to useSelector and here you know you can treat it like a higher order function by default you get a state in the function and you can return the state so you will see that nothing will happen in the state the default state will be the same here so see this and this is the same error that there will be unnecessary renders, you take the subscription carefully See here, city, valley, current null, error, forecast null. So how will we set the data in this? So to set it, we have made actions here. Success is getting, so you dispatch it. So let's dispatch it quickly. Here we are getting dispatch, we will dispatch it. What is the issue in this? What is the issue? Now tell me. Here we just have to dispatch. And what to do in dispatch? What to dispatch? Current success dispatch. Because it has become successful. So fetch current success. We will dispatch this. And what we have to send to dispatch? Just send the data. Which data to send? Look carefully here. Look carefully. This response that is coming to you. Reload it once. This response that is coming to you. This is the data name key in the response. And all the data is inside it. This header is not to be sent. This data has to be sent. This response that is coming to you. You have to send response dot data. This response is dot data. Okay. So you will send this data. We have set the data there in the payload. If you remember. So these are the things you have to keep in mind that what you have set here actually. See this action.payload. We are setting action.payload everywhere. So you have to send this data carefully because the data you are sending here is going as a payload. Okay. So this is done. In the same way, you will get fetch forecast success. And here instead of current weather details, we will send forecast details. Okay, we will send forecast details, but you see carefully which line number is in the forecast. Actually. 47 sorry 49 so line number 49 this is data and in data this is data key and actually in data key also this list we just need list we don't need anything else in this list we have full forecast details rest this city etc this noida etc we don't need all this we just need this list rest in this also many things are coming only with forecast our work No, it can't be. There are no more details like temperature etc. So, we are getting forecast details here. There is no problem in that. Where did it go? This was the key named data and in data, this list. So, forecast details dot data dot list. Okay. So, we have set this state. Alright. And we can remove this console now. Our work is done. We will reload. So, now see. Here in our state, in state, We have set the current details and forecast details too. Congratulations! So we got the current weather and the forecast weather. Now we just have to show it in the UI. There is nothing else to do. And we have to make the search functionality definitely. So do one more thing here. First of all, I told you that when it starts, it will be in pending status. So you didn't do this. Dispatch weather pending. dispatch fetchWeatherPending then only loading will be true and as soon as data will come then loading will be false and data will be set ok it is simple actually it is a little lengthy and nothing special ok we can't say it is complicated it is a little long rest it is simple and here try cache also so that if there is any error then we can use the action we have made for error ok so this is our try We will do all this work in try. And actually, we will do this pending status outside of try. Okay. It has nothing to do with try. Otherwise, it will try and no, it will be a mess. We will not keep it inside try. We will do the pending status outside. Okay. This will start. Then after that, the loading will be true. And then if it is successful inside try, then it is fine. So, in success, the loading will be false and the data will be set. Otherwise, we will dispatch it in error. FetchError, which we had made an action. And we had to send some data in it. Okay, we had to pass an error in it. So you can also pass as it is error. Or here I will pass a message of something went wrong. Something went wrong. So this message will go and be set in error. Okay. So this will be you have try catch. Properly we have configured all things. I think it's fine. Everything will work properly here. We will just dispatch fetchWeather and it will dispatch from inside. And you can get this written in many places. This which you made separately, this whole action was made separately. You could just pass this object here. While dispatching, you could simply pass this object. So in dispatch, you can think for yourself what is a plain JavaScript. Why are we calling action as a plain JavaScript object? because at the end, that object is going to the reducer. So we are targeting the object. So here in dispatch, you can also send the object. You just have to send type and payload. Or you can call the function here. So if you call the function, then at the end, what is it returning? The object is returning. So now think, what is the dispatch doing? It is working on the object. It is not like that if you make a function, then it will work. So you can get that syntax in a lot of places. So you see. Rest, it looks a little clean to see, so I did it this way. The code is a bit long but it looks clean. Alright, so the fetch weather is done. We are able to do the fetch properly. There is no problem anywhere. Now we have to set the city first. For the city, we have to make a component. We will make a new folder in src called components. And in components, the first component we will have is search component. search.jsx Alright, rafce And I will take the search component from daisy UI here. Now it will be in the need of daisy UI. Search. So you take the search component here. Which one will you take? Tell me quickly. This is fine, but it doesn't have a button and it has a button. So what to do? Take this button one and put this search and this icon in it. Or take this search one and put the button separately. Let's take the search one and put the button from here. And what's inside this? Look carefully. Inside this, you have a div whose class name is join. Okay, you just have to put the class name join, it will be joined with the button. So what's the problem? So let's take this one. Where did it go? Oh, that search was there, right? Which one? This one. So take its JSX, copy it from here and put it here quickly. Here it is. Okay. And then where did that join one go? Look at the preview. This is the preview. So take JSX from here. You have to put a class name outside, the join one. So alright. And in this div whose class name is join, we have this label. this input field and also we have to join a button so where is the button component here is the button so we will put this button down here and hopefully it should work and join come to app.jsx and put this component quickly and see the search Search component is imported from the right place. Okay. So, wow. Perfect. Perfect. Perfect. Perfect. Perfect. Do one thing. Give it div and class name. What can you give? Class name. Give padding of 10. And for now, this is enough. Make it flex. And make it flex column. Along with item center, it will come in between. So this search is done and if you want the button here, then instead of neutral, you can give secondary, primary, success. What have we given in this? Success is given in this or info is given on the side. I remember these classes, if you don't remember, then you can come here and see. If you search for buttons here, then you will get multiple classes for buttons. These are different colors. The class name is different here. Ascent, info, success, warning, that's it. Nothing else. So we have it here. So this blue color came. Was it ascent? Where did the button go? What will we have to do to write logic? We will have to write. But how will we write logic? What will be the logic here? We will have something like this. Here we have made one. Where? Come inside the reducer. Not even inside the reducer. Come inside the action. Set city function. Set city action. So we will dispatch this set city action. We will put city in it. And our city will be set. In direct state. So that's all we have to do. So come inside the search. Input which was ours. Where is the input? Here is the input. So in this input type you have search, required, placeholder is given. Here you have to put onChange. And in onChange you have to dispatch simply. Cons dispatch is equal to use dispatch. And this dispatch you have to use here. And not directly, actually you have to use it like this. because you have to call dispatch, so you have to make a function separately. Otherwise, if you simply want to pass a reference of a function, then make a function separately. Handle input. Handle input. And here you work. Const handle input is equal to. And we will simply dispatch set city. Okay. Set city has been imported here properly. Very good. Remove this. We have to put the city in the set city. From where will the city come? An event object must be coming in the handle input. Because we have passed the reference. So it will be set by e.target.value. So whenever we type, it will be changing directly in the state. The city must be saved in the state. Really? Yes, really. See this. As soon as I type here, the city is Delhi. I will type Noida. So Noida did not happen. Why? Noida should have happened. We have set the console as full state and our handle input is running in the search. Let's see if the CLG is running. It is running. So why is it not dispatching? Tell me. Is the set city not being dispatched? We have not given the proper type of the set city. If the type is wrong, then the reducer will not be able to match the type. Set city should work now. Let's reload. I set the noida here. See, the state has changed completely and it is also reflecting. Very good. So our set city is working. Alright. So here our set city is done. But now it is not controlled. It is not controlled because we have not set the value here. By default, when we reload, there is a valley in the state, but there is no valley here. So here we have to use the useSelector and take the state. const useSelector and state. Should we take the full state subscription or not? Tell me quickly. So const state is equal to and CLG state. So, in app.jsx, the state is not working, we were just checking whether our work is happening or not. And we will also fetch this fetch in app.jsx. So, we will do the fetching work here. Dispatch is fine, we don't need the state here, we don't need the useSelector here. So, we are doing the fetch here and we need the data here. And that's why we are managing the state so that we can use it wherever we need it. So, we have done all these things with the handle input. The state is coming here. Let's reload it once. And something went wrong. UseSelector is not defined. So, have we removed UseSelector here? We had removed it from app.jsx. We have removed it from here too. UseSelector. Okay. Define it here. AccessStateBeforeInitialization. Okay, not like this. Here, the state has to be returned too. State. All right. Let's reload. You are getting the whole state. But you don't have to take the whole subscription at once. Like you took the subscription of the whole state. You took the subscription of the whole reducer. And not just the reducer. You took the subscription of the whole state. Because you have not made multiple reducers. You have made only one reducer. And in this one reducer, you have all the states. So in total, you took the subscription of the whole store. That's why it says multiple re-renders can be triggered. If the forecast changes, the error changes, the current changes, then also the re-render will be triggered. Whether the city changes or not. So here if you want dot city access, then just take the city access, don't take the rest of the access. So see the city is coming to you. And do one thing here, if you are setting up, then the reducer you have made inside the reducer, maybe you have multiple reducers coming. So if multiple reducers are coming, then you will have to combine the reducers. So let's make index.js. And here we will import combine reducers. And here we will combine by using combine reducers. all our reducers. So here you have an object, in the object, we are keeping the key value pair here. First of all, our vader reducer, if there are more reducers, then you can take that reducer too. And in return, you get a root reducer here. Give the name of this combined reducer. So basically, by using the combined reducer, we can combine all the reducers. If there are more reducers, they will come here. And export default root reducer. Okay. Now we will import this root reducer here. import root reducer from where is it imported? This dot slash dot slash wrong place we imported. Oh, why are you bringing root reducer in weather reducer? In store, right? So import root reducer from dot slash reducers slash index. It had to come from index, right? So we will put this root reducer here instead of the weather reducer. So remove this weather reducer from here. So we have put the root reducer. The whole work of the store is complete. Now in the index, you will list all the reducers that you will get. And you can list the key value pair in this way. Weather reducer. Reducer. And here is the weather reducer. But here because I had to give the same key and the value was the same. So here I can use single in that way. You know this is how the object is used. And if you want to change the key, you can do it here. Like you can give it a weather name here, weather details. Okay, you can do this too. So if you gave the name weather details here, then if you come here and see the state in the search, then in this state, see what you see in this state. Deload it. So see, you can see the key weather details. You have the whole store. There are multiple reducers in the store. The first reducer you have is weather details. Okay, because we changed the name of the weather reducer and put weather details in the key. And along with that, we had connected Redux, basically connected DevTool with Redux. So here you can see all these things in Redux. That basically you have a state, a reducer, in which you have these weather details and all these things are coming in it. If you make multiple, then you can see everything here. Data is being saved in current and forecast. You also have Delhi as a city. If you try to change something by typing something, then you can see that it is also changing. And you can see all the actions that are being triggered. You can keep track of all this. DevTool is very strong. You can keep track of all the actions that are being triggered. And we can see everything in the state. And we are also getting to know in the console. So you are getting the weather details. And you should not take all the subscriptions as he is saying. so here I only need city so weather details and from there also I will take access to city only when it will change in city then only our rerender will trigger otherwise the rerender will not trigger so this is a good thing good practice and here in value I will put that city so as soon as it will change it will also connect in value so see I reload so it is connected to your state delhi and as soon as I change to noida, it will be searching the details related to noida and I have to search on the button click so in the starting I have to fetch the details I have to search on the basis of the default city so let me do one thing const city is equal to useSelector state state.VedalDetails.city So in the default state, we will search on the basis of that. We will search on the basis of this only once. And if there are any changes in the search, then it should be searched on the basis of clicking on the search button. So here we put onclick on the button. Handle search button. Okay. And here const handle search button. See, it takes time to write neat and clean code, but you have to write in the same way. It's not like you're writing code to save time. No matter how big a project you make, it doesn't matter. If you're writing a bad code, it doesn't matter. If you're making a small project, if you're writing code neat and clean, if you've managed everything properly on a production basis, you can make that project as big and scalable as you want. But if you're writing the code in a dirty way, it won't be fun. So handle search button and here we will dispatch. What will we dispatch? Tell me quickly. We have to call the same function, FetchWeather, and pass the city here. That's it. As soon as you click on the button, our search will be done. Let's reload. If you want, you can see the extension we have installed here. So now the city is Delhi. Let's do Noida here. So now you see here. So this Noida has come. And as soon as you search, you will see that the details will change. See, whose details are you getting now? You are getting details in current. here it is not visible in main see main city name is not visible actually see the name is dheli if i will search then the details of noida should be set here if it is working properly then in current in current it is visible it is small so let's do one thing let's see here here so current and in it main where is main not main, name, you have name, Bhagalpur has come, why, how Bhagalpur has been searched, ok, how Bhagalpur has been searched, do one thing, first of all, come here in weather action, and here you see in details, whether the right details are being searched or not, let's do CLG for a while here, CLG, current weather details, current weather details.data, ok, reload, So now whose details are you getting here? Whose details are you getting here? In the main, you have everything here. The name is coming from Delhi, right? After the main, the name is Delhi. So details related to Delhi are coming. Let's search Bhagalpur. And let's click on it. So again, your API got called. And here are details related to Bhagalpur. Now I have to search Noida. Let's search. and here you can see the data related to noidas so it is working properly, no issues and we are setting the data so now our work is done, the application is finished just make the UI and list the data, that's it the application is over now so the search component is done now what else we have to make and here we have to make a component where we will show the current weather weather.jsx r-a-f-c-e and here we will come to daisy UI and use a simple card. Isn't it? Search quickly. If you take so much time, then how will it work? Sometimes I don't know, the net is completely dead. And I get so angry that I don't know what to say. The whole time is being passed. Okay, so search will be done. It was very difficult to search and it seems that there was no search. We had to search for a card here. So which card is simple? We need details like we are showing here. And this is also actually taken by us. So there will be some kind of card, that's why we have taken it. This one was I believe. This is the one. So copy JSX here and paste it here in the current weather. So here you will get the details. You know that you have saved the details in the state. You just have to use the const here. Once you have set up, it is very easy to use. UseSelector, state, and whose subscription you have to take. So take the full one. There you have the current details. So you just have to take the subscription of current, nothing else. Actually, you have to take the loading too. details. So if you want, you can take the subscription of the whole reducer. But keep in mind that if it changes in any other state or in any other key, then your render will be triggered. Okay. So let's take it. There is no issue. So in weather details, you had to see the current and loading. Okay. Let's see by doing CLG. We have details coming. Current and loading. And you can attach it here in app.jsx. Attach it quickly. Just below search. current weather so come here quickly here reload so you can see the data in currentweather.jsx see loading was false first then true then again loading was false as soon as data came loading was false in starting loading was false but in pending status loading was true and as soon as data was found loading was false again so if loading is here which component was currentweather bring it here If loading is true, return a loader. I won't make a loader right now. I don't have any mood to make a loader. So I'll show loading dot dot dot like this. So as we reload, see, loading was shown to you. It was shown a little. See, loading was shown. Then it came after that. Alright. And if you want, give it a little padding in the class name of 10. Padding will come from top to bottom. See, loading happened. And then these details are coming. and in current you can see all the details so in details you can see the name here where you can see the cookies you can see the name here current.name ok so you can see the name here and what else you can show whatever you want to show here you have a lot of things here you can show what is here weather status is foggy etc etc what i am showing here i am searching so temperature is showing humidity is showing weather is showing so i am showing only this much temperature humidity and weather and if you don't want button then remove the button temperature is needed so from where temperature will come first see this from where temperature will come so this main key in main you have temperature main dot temp ok current dot main dot temp so from here you have temperature What else was needed? Humidity was needed. So, here is humidity too. So, copy it. In main, you also have humidity. What else was needed? Tell me. You can also show pressure. You can show whatever you want. I am here on the 0th index of a weather. You have an object and it has a description. So, on the 0th index of a weather, is a weather an array? weather is an array which has an object on the 0th index and inside that you have what was it? description? yes it was description so yes it was description so this is your temperature temperature temperature ok this is your humidity humidity alright and this is your weather what kind of weather is it? So you can see it properly here. It must be looking good. And the temperature is coming in Kelvin here. If you want, you can convert it to minus 273. So it will be converted to Kelvin. With whom did I minus? I did minus with the name. I am so sorry. Here 273. So it came in degree. Okay. Sorry, it came in degree Celsius, but it is coming after a lot of point. So we will do one thing, we will fix it by fixing dot 2 to 1 decimal place. So 12.2 and show degree Celsius also. Now how will you show degree? Is there anything like degree? How can we show degree Celsius? Keyboard does not have a degree key. How did I show it here? So copy and paste it here. I also took that from Google. You will search here on Google. So some things like you are not getting any emoji or anything. So you will search here and it will come to you. Degree Celsius you will search. So somewhere like this Degree Celsius is written. So copy it like this from here. If you don't understand, you are not getting it on the keyboard, then you come here and paste it. Take this. Okay. Degree Celsius. Got Degree Celsius. Satisfied. Okay. So, this is done. Humidity is this much. Percent. Show me percent here. You have percent. And fog is done here. After that, you need forecast details. So, this is done. Current weather details are done. Now, make another component here. So, see. You have managed the state properly. After that, make any component. Make anything. You can use it easily. It is the first time that the jhamela happens in state management. So current weather and here it will come forecast details.jsx rafc alright and here also again you have to do the same thing. So come to current weather and if error comes then handle the error one too. If error comes then we will return it. We have passed error. Something went wrong. So here you will see the same error. Okay. And let's say if there are no details. If current is null. If there are no details, then also we will return null. Means we will not return anything. If there is no current, then we will not show this. So here we have put all the conditions. And our current weather is complete. Now let's come to forecast details. Const forecast, loading. We will remove this also. Use selector state state dot weather details and after doing CLG first check whether the forecast is coming along with loading or not after current weather you will get forecast details ok done reloading some error came error is not defined that error must have come from here error is not defined obviously error is not defined because error is from here It is not taken. Now it is fine. See, loading is coming. After loading, our details are visible here. And here it was false, true, and then after the data came, it was completely false. So you have an array. Okay. So you have to work on the array here. So it's not a big deal to work on the array. We know how to do it. So here the current weather UI, let's copy the same UI here. In forecast details, we copied the same UI here. And what to do? So, it's okay till h2, we have to replicate this paragraph basically. So, remove these two paragraphs, our work will be done in one paragraph. We will map like this here. So, forecast details, not forecast details, here forecast. Forecast you have a array, we will map dot, you will have one item coming and we will work on that item and return it. That's it. That's it. And right now we don't have this temperature or anything, so remove this. So here you can see degree Celsius, degree Celsius. Current is not defined. Okay, current is not defined. So who is saying current is not defined? He is saying this. So here, four days forecast. Reload. Cannot read properties of null reading map. Okay. Is there any details in forecast? Details should be there. Details were coming actually. It is possible that the problem is happening here because of the null in the starting. So if you have a forecast null, then we will return null here. And if there are forecast details, then there will be details here. So when the forecast details will come, then you will have this rendering. So here you can see only degree Celsius, degree Celsius, because we have not shown anything else yet. So let's show it. Unique key prop is asking to give this, so we will give it here. What is the problem in the paragraph? Key item dot ID will have to be given, right? Is there any ID in it? If there is no ID, then do one thing, take the index here and pass the index. Now how to show here? So how to show here? In this way you need a date string and here you will show your own in degree Celsius. That's it, your work will be done. So open one here and one will do your job. And if the loading is true, then here also I have to show loading. If loading is true, then return it. And see, we made the same loading for both. So if current weather details come, then also loading will be false. And if this comes, then also loading will be false. Which came first, loading will be false for both. So that's why I was saying, make different pending and error status too. So it will be good. So here, loading dot dot dot. That's it. Okay. And don't show loading here. If it is made only once, then there is no point in showing loading twice. Both have to be false at the same time. So what will you show? One loading is visible above. This will work for you. So if the forecast is not here, then it will not come. Rest, if there is any error, if there is any error, then we will return a paragraph where this error will be shown. And you can style it. You can show the error in red color. So I am not going to do all that now. Okay. Very good. Everything is done here. And here, see what details you have. CLG one item. So one object must be coming to you. In that object, see you have date. text is coming. So you take out this date text from here and show it here. Item dot date text. Okay. So this date text has started to show you. Along with that we have to show temperature. So from where will the temperature be seen? So in main you have temperature. Like we did in current weather. So same work we have to do here. Okay. Let's format it a little bit. And some close it a little bit and here item.dateText and here you will get item.main.temperature and then here degreeCelsius so very good and in degreeCelsius again we will have to convert it so minus 273 and if you want to show the whole to 1 decimal place then. 2 fixed and here pass 1 So our project is ready. So we didn't do much, we had loading here. There is no need to show loading here, we are doing our work with the same loading. So here the forecast is complete, we have mapped it, we have shown the date text here and shown the temperature here. That's it, we will see our forecast for four days here. Current weather component is also made here. We have also made the search properly, managing the state properly. And whatever style you want to do here, we will do a little bit here. Let's give a gap of 10. So there will be a little gap between all of this. And we are done. Okay. And a little bit of this is sticking up. If you want to make something sticky, you can make it. It's your choice. It's your choice. So let's make it. No problem. The search component is here. If you want, you can make it sticky. Top say 0. Top say 10. and this is sticking, but Z index is a little less, increase Z index, so it came up, but it is not that interesting to come up, give a little color to it, so give BG base 100, so it will match the background, okay, and I think with full will have to give, then go and Okay, background is here. So, do one thing here. In search, we have given some 10 from top. Don't give 10 from top. It will stick up. You have to give something. Like top is 0. So, it stuck up here. Very good. Let's do one thing. Let's give padding of 10 in this. So, see, it is coming in this way. So that's all we have. And just a heading is written on the top. Vader dashboard. So you can write that here. So let's do one thing. This one who is doing this useless garbage. They are playing here. They don't play this garbage here. Let it be like this. And let's do our job here. There will also be a heading here. H1 Vader dashboard. And here we will give the class name. So abhi ye thik lag raha hai. Badiya lag raha hai. Maza raha hai. Aur isko flex bhi de do. Item center kar do. And flex diya hai to ye aju baju a jayega. To flex call kar do isse. Flex column. Badiya. Isse tarikaya se a gaya. Aur heading mein thoda sa text. 4xl type kar do. Aur margin bottom se de do. 2 ka. To ye kuch aisa a raha hai. 3xl deke deko kaisa lagta hai. In 3xl it looks like this. And it looks good. And from margin bottom we have given 2. See how it looks from 6 it is looking like this so rest you can style it we have done it we are not going to style it so it is done properly and details are fetching if you want then from here the console you have done where we have done the console in forecast so from forecast you remove this console and if you want to see any state by chance So now you can come here and see the state inside Redux, how and what is happening. See whatever action is being triggered, you will see everything here. Reload, by default, the data of Delhi is being fetched. I want data of Noida here. So see this, set city is being set to you. How many times it was called, how many times it was triggered, you can see everything. You can also go to the history and see how and what calls have been made. And like join, we have given the join button. Change the button a little. The search button is ours. Where is the search button? Here it is. Not join here, search will be done here. Search. So as soon as we type Noida and search, Noida's related details are coming. If I put Bhagalpur here, then Bhagalpur's related details will come. If I put Kolkata here, then Kolkata's related details will come here. So it's coming here with perfect details. And see why it has stuck like this. Basically, isn't its width full? Isn't the width full? We should have taken the width full, but why isn't it taking the full width? Because it has given padding of 10. Remove this. Now it is perfect. Now it is perfect. Now it is perfect. And we have given 6 from the margin bottom. We have given a very good gap of 10. So... If we remove the gap, then the gap between it will disappear and everything else is fine, but we can do a little work here. We have given the padding of 10 in it. We had to make this kind of sticky behavior, that it should be a little down and then after that it should go up and our work is happening. So this can also be done. Give the padding Y of 10 here. So now it is working in exactly the same way. So UI, I don't know why I go to UI. So our work is happening properly. This is important. Whatever search is coming to us, search is coming to us. Properly loading is happening. We are managing the state. Here we can see how it is being managed. We can see in the chart. We can see in any way we want to see. And here we can also fetch how and what is happening. Fetch means basically you can see how the set city, fetch current status, fetch loading happened. Or whatever happened to you, you can see it here by tracking. You can see whatever you have done so far. So this is how our work has been done, we have done this and this is how you are triggering everything, you are getting the chart of everything here. DevTool is very interesting, so that's why it looks very good here. Redux toolkit will be better because code is simple and performance wise it is as strong as redux. Code is simplified and constants and actions are auto generated. The work behind the scenes is the same as in state you had to focus on immutability manually. using dot dot dot spread operator to focus on immutability. Now, it's not like that. You can mutate there, but actually it won't mutate. And what I am saying, I will tell you there. Okay? You will be a little shocked to see that, okay, did they simplify it so much? Did they simplify Redux so much? Definitely. React-Redux will be the same as we read in Redux. About React-Redux, useSelector, useDispatch, and the subscription funda that explains how the render is triggered, that is exactly the same as React-Redux. What we are going to read separately is Redux Toolkit. We have read Redux. Now Redux Toolkit is an abstraction of Redux. Redux is abstracted, code is hidden, you don't have to see the code that much. You will work on a small code for which you use Redux Toolkit. So, what is Redux Toolkit? It is a state management library. You have already done Redux. You just have to read Redux Toolkit, which is a state management library over Redux. So, if you got this, that means you got Redux Toolkit. Okay? Rest, I will tell you properly from the core again. Because those who are not interested in Redux, many people say that don't read Redux. Why do you have to do Redux? But I think it is necessary. It is necessary. That's why I told you. They have to know Redux Toolkit, they don't have to know Redux, there will be a proper solution for them in the future. Okay, so our project has been made properly. Okay, I will close everything and push the code here for you. And whatever error is there, there is nothing now. We will cut, cd dot dot, I will come inside the react folder and I have to push the whole code, so git add dot, git commit slash m. Redux project. And status. You check. That everything is done or not. Done. And git push origin main. So I have pushed properly. And you will get the code. You can go and see. And alright. Thank you so much. See you in the next lecture. Till then explore. A little bit of Redux toolkit. And bye bye.