Redux Made Easy | Learn React Redux | Redux Tutorial for Beginners

  Рет қаралды 9,941

Dave Gray

Dave Gray

Күн бұрын

Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap
Redux made easy to learn and apply to your project. Learn React Redux in this Redux tutorial for beginners. Redux has long been the state management solution for React. Easy Peasy Redux is an package that makes redux easy to add to your project.
🚩 Subscribe ➜ bit.ly/3nGHmNn
🚀 This lesson is part of a Learn React tutorial series playlist:
• React Tutorials
🔗 Project Source Code: github.com/gitdagray/easy_pea...
Redux Made Easy | Learn React Redux | Redux Tutorial for Beginners
(00:00) Intro
(00:05) Welcome
(00:16) Overview / Goals
(01:26) Uninstalling packages
(02:27) Installing Easy Peasy Redux
(02:51) Starting the dev environment
(03:37) Creating the Easy Peasy store
(13:03) Refactoring index.js
(14:10) Refactoring App component
(17:51) Refactoring Nav
(21:20) Refactoring Home
(22:14) Refactoring PostPage
(24:41) Refactoring NewPost
(27:56) Refactoring EditPost
(33:46) Quick clean up
(34:33) Async clean up
(35:48) Refactoring Footer
🔗 Easy Peasy Redux:
easy-peasy.vercel.app/
🔗 Rules of Hooks:
reactjs.org/docs/hooks-rules....
🔗 Collections of Hooks:
nikgraf.github.io/react-hooks/
www.npmjs.com/package/react-use
🔗 Axios:
www.npmjs.com/package/axios
🔗 React Router:
reactrouter.com
🔗 JSON-Server:
www.npmjs.com/package/json-se...
🔗 ES7 React JS Snippets Extension for VS Code:
marketplace.visualstudio.com/...
🔗 React Dev Tools Extension for Chrome:
chrome.google.com/webstore/de...
🔗 Styled Components: styled-components.com/
📚 References:
ReactJS Official site: reactjs.org/
React Wikipedia: en.wikipedia.org/wiki/React_(...)
React Jobs: www.ziprecruiter.com/candidat...
✅ Follow Me:
Twitter: / yesdavidgray
LinkedIn: / davidagray
Blog: yesdavidgray.com
Reddit: / daveoneleven
Was this tutorial about Easy Peasy Redux with React helpful? If so, please share. Let me know your thoughts in the comments.
#react #redux #easy-peasy

Пікірлер: 58
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
I really like Easy Peasy. It is an abstraction of Redux - that is Redux is running underneath it - and Easy Peasy makes the usage...well, easy! Redux can be difficult to learn, but I wanted to add something about in this Learn React beginners tutorial series. If you are just starting out with React, go to the beginning of the Learn React series here: kzbin.info/aero/PL0Zuz27SZ-6PrE9srvEn8nbhOOyxnWXfp
@chrisstucker1813
@chrisstucker1813 Жыл бұрын
Context is nice for smaller use cases. But I must say that redux provides a much more robust and organised approach. It sort of makes it easier to envision the various states being managed across different components. For instance in the nav component: when you alter the searchResults and send the payload to the Redux store, it then causes a refresh in the home component because that is using the searchResults state. So when you update a state, it gets sent to redux then relayed back the components that use that state then causes a re-render of the component with the updated state. It makes the whole flow of state much easier to follow IMO
@MASTERRAGE
@MASTERRAGE 2 жыл бұрын
Thanks god i found this gentlemen, good job sir keep it up
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! 🙏💯
@user-ml8rz2js9m
@user-ml8rz2js9m 2 жыл бұрын
Amazing contents sir!!!, thank you very much
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! 🙏
@spicythunder4462
@spicythunder4462 2 жыл бұрын
Thank You.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome Spicy!
@sakibcoder
@sakibcoder Жыл бұрын
CONGRATS FOR 100K
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thanks!!
@sonamohialdin3376
@sonamohialdin3376 2 жыл бұрын
Amazing tutorial
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad you liked it! 💯
@sonamohialdin3376
@sonamohialdin3376 2 жыл бұрын
@@DaveGrayTeachesCode Thank you very much
@ivanfrey6323
@ivanfrey6323 Жыл бұрын
Hey Dave, loving the content. I am a bit confused, do you think you could better elaborate on what the payload exactly is? I feel like your explanation was brief, maybe hearing more from you could clear up the confusion? Thank you!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Hello Ivan - yes, Redux can be confusing. If you look at the store.js file, you see that we have different actions like setEditTitle that receive the current state AND a payload as arguments. The payload depends on what the action is. For setEditTitle, if we look at the EditPost.js file, the onChange event of the title input allows us to pass in a new title for the post. That is the payload for setEditTitle. In the same way, setEditBody receives a payload that has text for the body of the post. I hope this helps!
@ivanfrey6323
@ivanfrey6323 Жыл бұрын
@@DaveGrayTeachesCode Ahhhh I see, so it's essentially like the parameter that will either override the state or be appended to it, I think I get it now. I think payload is just a weird name for it, but I see, thanks a lot Dave.
@olimeunier
@olimeunier Жыл бұрын
Thank you Dave for this video. Nothing works anymore with React Router V6...
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
You're welcome - In the course resources, I shared an update to this blog project for RRv6. Here is a link: kzbin.info/www/bejne/jnO1fYmIn79mebM
@skillkrio
@skillkrio Жыл бұрын
Dave in 16:45 you are adding setPosts as dependency list before we didn't added setPosts as dependency list in the context api. Why are we adding setPosts as a dependency over there?
@skillkrio
@skillkrio Жыл бұрын
Hi i think you didn't noticed my comment for better reach i am replying here
@metquadi
@metquadi Жыл бұрын
thanks teacher. but I feel React context is much easier to use. I wonder when I need to use easy-peasy ?
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
It is your preference or your team's choice. Redux is used most often for larger applications with a lot of state to keep track of.
@metquadi
@metquadi Жыл бұрын
@@DaveGrayTeachesCode thank you teacher. I am very grateful to you.
@liranEX
@liranEX 2 жыл бұрын
Tip: new way of state management do on a new project. this change made me look 100 times at every line to make sure i wrote it right.
@liranEX
@liranEX 2 жыл бұрын
plus filteredResults return empty array for me :(
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Compare your code to my source code to find the differences. Source code available in the resources.
@zman7357
@zman7357 11 ай бұрын
@@DaveGrayTeachesCode mine was also returning an empty array, I cloned the chapter 22 repo, ran npm I, but then when I run npm start I get the error: Error: error:0308010C:digital envelope routines::unsupported.
@skillkrio
@skillkrio Жыл бұрын
I am commenting again as my previous comment didn't get noticed Dave in 16:45 you are adding setPosts as dependency list in App.js and also adding setSearchResults in Nav.js before we didn't added setPosts/setSearchResults as dependency list in the context api. why are we adding that?
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
I'm not entirely sure what you are asking - but I'll attempt to answer. We are using Easy Peasy Redux here and not Context. When you say "dependency", it makes me think of the dependency array in the useEffect hook - and maybe that is what you are referring to. You do not need to add the setState function (whatever it is named... setPosts, setSearchResults, etc) as a dependency in useEffect in the current version of React (currently v18). In the past, you didn't need to either BUT React would provide a confusing dependency warning saying that you did need to... so I just included them. If not, I would likely have had many questions about that warning. So to sum up, you can skip putting any setState function in the dependency array for useEffect. I hope I answered the right question.
@skillkrio
@skillkrio Жыл бұрын
@@DaveGrayTeachesCode why are you adding setPosts in the dependency list? It's just a useStoreActions in 16:45 time frame. During that video you told that ohh we need to add this because react complaints us to add like that
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
I just answered this question in my first reply? Quoting it here: "You do not need to add the setState function (whatever it is named... setPosts, setSearchResults, etc) as a dependency in useEffect in the current version of React (currently v18). In the past, you didn't need to either BUT React would provide a confusing dependency warning saying that you did need to... so I just included them. If not, I would likely have had many questions about that warning. So to sum up, you can skip putting any setState function in the dependency array for useEffect. " Also, to insure your questions are answered and seen, please join my Discord: discord.gg/neKghyefqh
@skillkrio
@skillkrio Жыл бұрын
Thanks alot Dave i feel like incomplete after finishing the series. Now makes sense. Thankyou so much Dave
@chammyae9987
@chammyae9987 Жыл бұрын
Hello, I follow along this series with no problem but in this one after changing from Context api to easy-peasy, states are not updating. Posts are not showing when I reload. I can't type on form, I can't add post. I can't edit post. Can anyone tell me, what is happening. I'm so confused right now.
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
I would only be guessing about your code. Compare your code to the code available at the course resources link in the description.
@DoraG0N
@DoraG0N Жыл бұрын
@@DaveGrayTeachesCode hello sir .. I have the same problem that Cham's has , idk if it's coincidence or may be there is a problem with react v 18 or something, (I'm sure I did the same code as yours and I checked it many times :( .. )
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
@@DoraG0N If you think it is React 18, this video may help: kzbin.info/www/bejne/bmLJko2wpZZrhK8
@shoaibkhan-eq8vp
@shoaibkhan-eq8vp 8 ай бұрын
Heyy guyss, can somebody help me! I followed this tutorial step by step but I'm getting an unknown error like their is not error message but the app is not visible. As I'm using latest vision of react router. I made a file called layout and in that file I use Outlet In between nav and footer. I think I'm unable to understand the syntax of easy peasy merging into react router (virsion 6), Is their anyone who can help me??
@samiullahsheikh5015
@samiullahsheikh5015 2 жыл бұрын
Can someone just use utility function (regular function) instead of custom hook like your useAxiosFetch() for api call? And can return arry of data, error and loading Return [ data, error, loading]
@samiullahsheikh5015
@samiullahsheikh5015 2 жыл бұрын
And that function can be used in thunk as well
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
It is Javascript, so yes, you can create a function. Thinking in a Reactful way, it is preferred to create a hook. Hooks do have some benefits in React. This video dives deeper into creating Axios hooks: kzbin.info/www/bejne/hKLHoqGcr7SEfKc
@abdulrahmanagboolaosho3582
@abdulrahmanagboolaosho3582 Жыл бұрын
Could you please do a react native tutorial
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
I want to do this. It will be next year sometime before I get the chance.
@dafiraone
@dafiraone Жыл бұрын
I have a question, how do you manage your directory & file names with camelCase/capital? is there any rules for naming?
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
It can depend on the team and project. Go with the rules of your dev team at work. For your own projects, many approaches can be used. I should create a video for this 🚀
@salehm5413
@salehm5413 2 жыл бұрын
If I used only easy peasy that mean I don't need to use redux !
@DeepakGupta-hj2dv
@DeepakGupta-hj2dv 2 жыл бұрын
please make on video redux thunk crash course
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thanks for the request! 🙏
@DeepakGupta-hj2dv
@DeepakGupta-hj2dv 2 жыл бұрын
@@DaveGrayTeachesCode please also make a video redux saga and redux toolkit crash course
@kylesheen7432
@kylesheen7432 2 жыл бұрын
Pros and Cons of Redux vs Context?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Good question, Kyle - The answer could probably be its own video. TLDR: Context is built-in and simpler. I would use it for simple and medium-sized projects. Easy peasy redux is the easiest version of Redux I have seen. You could also use it for small and medium projects. Redux toolkit is only for large complex state management. You would see it in Enterprise level projects.
@Ruhgtfo
@Ruhgtfo 9 ай бұрын
Failed to load resource: the server responded with a status of 404 (Not Found) >< help
@DaveGrayTeachesCode
@DaveGrayTeachesCode 9 ай бұрын
Sounds like you need to start json-server.
@Ruhgtfo
@Ruhgtfo 9 ай бұрын
@@DaveGrayTeachesCode will try after thanks for sharing ~ :D
@elAmigo805
@elAmigo805 8 ай бұрын
I keep getting the following error but I can't trace it anywhere: Home.js:12 Uncaught TypeError: Cannot read properties of undefined (reading 'length') at Home (Home.js:12:1) all I have there is the {fetchError} in the p element that is inside the : {!isLoading && fetchError && ( {fetchError} )} Anyone else resolved this issue?
@miq_5239
@miq_5239 3 ай бұрын
Hey, I have the same problem. Did you fix it by any chance?
@elAmigo805
@elAmigo805 2 ай бұрын
I think I had destructured searchResults instead of leaving it as a const variable. It was a simple mistake for me. Not sure if you have the same scenario. I should've had this: const searchResults = useStoreState((state) => state.searchResults); but I had this instead: const { searchResults } = useStoreState((state) => state.searchResults);
@benedictmoeti5162
@benedictmoeti5162 Жыл бұрын
Too much information. This video should be labelled "for intermediate to advanced users". Not for beginners
Они убрались очень быстро!
00:40
Аришнев
Рет қаралды 3,1 МЛН
Each found a feeling.#Short #Officer Rabbit #angel
00:17
兔子警官
Рет қаралды 7 МЛН
When Steve And His Dog Don'T Give Away To Each Other 😂️
00:21
BigSchool
Рет қаралды 17 МЛН
Купили айфон для собачки #shorts #iribaby
00:31
TOP-18 ФИШЕК iOS 18
17:09
Wylsacom
Рет қаралды 728 М.
#miniphone
0:16
Miniphone
Рет қаралды 3,1 МЛН
WWDC 2024 - June 10 | Apple
1:43:37
Apple
Рет қаралды 10 МЛН
Купил этот ваш VR.
37:21
Ремонтяш
Рет қаралды 234 М.
iPhone 12 socket cleaning #fixit
0:30
Tamar DB (mt)
Рет қаралды 38 МЛН