What if you need to manage more complex states? Here useReducers comes into play
React Hooks are so powerful and especially some additional hooks.
Do you know there is an alternative to useState called useReducer hook? It is used to manage more complex states.
Let's look into detail ๐งต๐๐ป
What if you need to manage more complex states? Here useReducers comes into play
The second value is a dispatch function using which we can update our state.
Here is the complete syntax ๐๐ป
I just implemented a basic code here. Basically, I am calling dispatch function on button click which will eventually call reducer function
Before that one thing to note here is that useReducer is for handling more complex states hence it is recommended to passing the current state as an object
Something like this ๐๐ป
Play around with it here: https://t.co/6BlaBeul1U
Here is "payload" comes into play. It is used to pass the value which represents the payloads of the action.
For example, suppose I want to pass "temp" variable ๐๐ป
https://t.co/6BlaBeul1U
Check out the code and try to play around with it for better understanding.
https://t.co/TCPEn0W3Pz
Check it out: https://t.co/nt4hZzInIR
More from Pratham
65 JavaScript resources that can help you
Mega Thread ๐งต ๐๐ป
๐น Websites
1. Java5cript
https://t.co/2gdB6LdfQ8
2. JavaScript Tutorial
https://t.co/YyH7YEZtOL
3. JavaScript 30
https://t.co/X2e6T9qFW5
4. JavaScript Info
https://t.co/GLcMZmyfC9
5. JavaScript by
๐น Learn through visualizing
6. JS Visualizer
https://t.co/DKXfCA5bnv
7. UI dev visualizer
https://t.co/IsnNdAGANq
8. JS
๐น Documents
9. MDN
https://t.co/XkMlZQOF0h
10. W3 Schools
https://t.co/aJB14ha9KT
11. DevDocs
https://t.co/sVwCCrYKwA
12. JavaScript Info
https://t.co/VJaTfVOIa8
13. JavaScript
๐น GitHub repo
14. Modern JavaScript tutorials
https://t.co/vDgTJKbz74
15. Awesome JS Learning
https://t.co/CUCBjfJEcY
16. JS by example
https://t.co/VLT6dRwLSp
17. 33 JS concepts
https://t.co/F5KDOSaACD
18. 30 seconds of
Mega Thread ๐งต ๐๐ป
๐น Websites
1. Java5cript
https://t.co/2gdB6LdfQ8
2. JavaScript Tutorial
https://t.co/YyH7YEZtOL
3. JavaScript 30
https://t.co/X2e6T9qFW5
4. JavaScript Info
https://t.co/GLcMZmyfC9
5. JavaScript by
๐น Learn through visualizing
6. JS Visualizer
https://t.co/DKXfCA5bnv
7. UI dev visualizer
https://t.co/IsnNdAGANq
8. JS
๐น Documents
9. MDN
https://t.co/XkMlZQOF0h
10. W3 Schools
https://t.co/aJB14ha9KT
11. DevDocs
https://t.co/sVwCCrYKwA
12. JavaScript Info
https://t.co/VJaTfVOIa8
13. JavaScript
๐น GitHub repo
14. Modern JavaScript tutorials
https://t.co/vDgTJKbz74
15. Awesome JS Learning
https://t.co/CUCBjfJEcY
16. JS by example
https://t.co/VLT6dRwLSp
17. 33 JS concepts
https://t.co/F5KDOSaACD
18. 30 seconds of
If you start with the right course then the process becomes a little easier
I found some amazing YouTube videos and courses that will help you start your Web Development journey
๐งต๐๐ป
HTML and CSS
- A great way to arouse your web dev journey with Gary's (@designcoursecom) course on YouTube
๐ https://t.co/xjm7nfV2L2
JavaScript
- Although it's impossible to learn JavaScript in 2 hours but JavaScript mastery is one the best YouTube chanel for JavaScript. This 2 hours long crash course will help you start your journey and gives you quick overview.
๐ https://t.co/1zcSeu4zKE
Git and GitHub
Git is an essential tool. And after learning JavaScript, I think one should go for Git and GitHub. Check out this free great course on Udemy
๐ https://t.co/E14cibOLXb
React
What you'll learn
- what problems React can solve
- how React solves those problems under the hood
- what JSX is and how it translates to regular JavaScript function calls and objects
- manage state with hooks
- build forms
๐ https://t.co/3z22aeVQFc
I found some amazing YouTube videos and courses that will help you start your Web Development journey
๐งต๐๐ป
HTML and CSS
- A great way to arouse your web dev journey with Gary's (@designcoursecom) course on YouTube
๐ https://t.co/xjm7nfV2L2
JavaScript
- Although it's impossible to learn JavaScript in 2 hours but JavaScript mastery is one the best YouTube chanel for JavaScript. This 2 hours long crash course will help you start your journey and gives you quick overview.
๐ https://t.co/1zcSeu4zKE
Git and GitHub
Git is an essential tool. And after learning JavaScript, I think one should go for Git and GitHub. Check out this free great course on Udemy
๐ https://t.co/E14cibOLXb
React
What you'll learn
- what problems React can solve
- how React solves those problems under the hood
- what JSX is and how it translates to regular JavaScript function calls and objects
- manage state with hooks
- build forms
๐ https://t.co/3z22aeVQFc