React Summary Day-9
Heyy Everyonee! This is day 9 of learning react from Hitesh Sir (Chai Aur Code). Today i learned more about context API and gained some confidence through project. The project was Todo app. May it seem so simple, but with context Api, its Not ! Its pretty complex, i need to watch it more 1 to 2 times to understand fully. And also i learned about local Storage. Local Storage actually very simple. It just has two methods, setItem and getItem, in setItem, we give key and the data to that corresponding key, and in getItem, by using the key we access the data. Thats it, this is Local Storage, another important thing to consider in local storage is, when we call the getItem, it returns the string, it may look like JSON, but its not! It returns string. So we need to convert it into JSON by using JSON>stringify() method. Thats all about localStorage.
Now, for the context API, its somewhat complex, but totally understandable. In this project, we created the todo as context, and all the functions it executes like addToTodo, editTodo, updateTodo, all this functions are defined inside context, i.e inside createContext method. AND as usual we wrapped all the components inside the variable that expects the props, where we give whose context we need to hold, and this variable give context of all the function and todo to the other components defined inside this variable component. Other thing is, we make the custom hook as useTodo, wehre we hold the context of todos. This is optimized approach to make the hook.
This is all about increasing confidence on context API and be comfortable with it. I am somewhat comfortable, but i need more practice. Other thing is this project rebrushes my javascript fundamentals, by using spread operators, first, its bit confusing, but later hitesh sir connected it so well, i get the whole thing and i am like, ohhh thats why did this earlier because this is happening, so overall, it brushed up my javascript fundamentals.
This is all i learned today from mere Todo app, it seems easy but hitesh sir introduced decent complexity to mere Todo app! Local Storage is easy, i now need to make command on context API.
