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
5 best color palette for every web developer and designer π¨
π§΅π
1. Color hunt
- Color Hunt is a free and open platform for color inspiration with thousands of trendy hand- picked color palettes
ποΈ https://t.co/xR0FVTjK0L
2. Adobe color wheel
Explore and create accessible color palettes using color wheel, in variety of color variations and contrast levels. It will tell you automatically if two colors are not accessible
ποΈ https://t.co/ndsgBauTEc
3. Palette Ninja
Palette ninja is an online color scheme generator that allows you to create harmonious color schemes in seconds
ποΈ https://t.co/cuzP21tn2Z
4. My color space
Here you can find the perfect matching color scheme for your next project! Generate nice color palettes, color gradients and much more! Your space for everything that has to do with color
ποΈ https://t.co/kmjrXOceAj
π§΅π

1. Color hunt
- Color Hunt is a free and open platform for color inspiration with thousands of trendy hand- picked color palettes
ποΈ https://t.co/xR0FVTjK0L

2. Adobe color wheel
Explore and create accessible color palettes using color wheel, in variety of color variations and contrast levels. It will tell you automatically if two colors are not accessible
ποΈ https://t.co/ndsgBauTEc

3. Palette Ninja
Palette ninja is an online color scheme generator that allows you to create harmonious color schemes in seconds
ποΈ https://t.co/cuzP21tn2Z

4. My color space
Here you can find the perfect matching color scheme for your next project! Generate nice color palettes, color gradients and much more! Your space for everything that has to do with color
ποΈ https://t.co/kmjrXOceAj

5 amazing websites that will blow the mind of a developer. Definitely check them out
π§΅ππ»
1οΈβ£ Animation generator
- Dead simple visual tools to help you generate CSS for your projects.
π https://t.co/IFmIEgDiVY
2οΈβ£ Neural Network Visualizer
- Deep playground is an interactive visualization of neural networks, written in TypeScript using d3.js.
π https://t.co/mTAlFbJsOW
3οΈβ£ Blockchain Demo
- A visual demo of blockchain technology
π https://t.co/I1RwxYcM1Z
4οΈβ£ Developer Roadmaps
- Step by step guides and paths to learn different tools or technologies
π https://t.co/VSNPdG8jQR
π§΅ππ»
1οΈβ£ Animation generator
- Dead simple visual tools to help you generate CSS for your projects.
π https://t.co/IFmIEgDiVY

2οΈβ£ Neural Network Visualizer
- Deep playground is an interactive visualization of neural networks, written in TypeScript using d3.js.
π https://t.co/mTAlFbJsOW

3οΈβ£ Blockchain Demo
- A visual demo of blockchain technology
π https://t.co/I1RwxYcM1Z

4οΈβ£ Developer Roadmaps
- Step by step guides and paths to learn different tools or technologies
π https://t.co/VSNPdG8jQR

You May Also Like
Joe Rogan's podcast is now is listened to 1.5+ billion times per year at around $50-100M/year revenue.
Independent and 100% owned by Joe, no networks, no middle men and a 100M+ people audience.
π
https://t.co/RywAiBxA3s
Joe is the #1 / #2 podcast (depends per week) of all podcasts
120 million plays per month source https://t.co/k7L1LfDdcM
https://t.co/aGcYnVDpMu
Independent and 100% owned by Joe, no networks, no middle men and a 100M+ people audience.
π
https://t.co/RywAiBxA3s
Joe is the #1 / #2 podcast (depends per week) of all podcasts
120 million plays per month source https://t.co/k7L1LfDdcM

https://t.co/aGcYnVDpMu

So it's now October 10, 2018 and....Rod Rosenstein is STILL not fired.
He's STILL in charge of the Mueller investigation.
He's STILL refusing to hand over the McCabe memos.
He's STILL holding up the declassification of the #SpyGate documents & their release to the public.
I love a good cover story.......
The guy had a face-to-face with El Grande Trumpo himself on Air Force One just 2 days ago. Inside just about the most secure SCIF in the world.
And Trump came out of AF1 and gave ol' Rod a big thumbs up!
And so we're right back to 'that dirty rat Rosenstein!' 2 days later.
At this point it's clear some members of Congress are either in on this and helping the cover story or they haven't got a clue and are out in the cold.
Note the conflicting stories about 'Rosenstein cancelled meeting with Congress on Oct 11!"
First, rumors surfaced of a scheduled meeting on Oct. 11 between Rosenstein & members of Congress, and Rosenstein just cancelled it.
He's STILL in charge of the Mueller investigation.
He's STILL refusing to hand over the McCabe memos.
He's STILL holding up the declassification of the #SpyGate documents & their release to the public.
I love a good cover story.......
The guy had a face-to-face with El Grande Trumpo himself on Air Force One just 2 days ago. Inside just about the most secure SCIF in the world.
And Trump came out of AF1 and gave ol' Rod a big thumbs up!
And so we're right back to 'that dirty rat Rosenstein!' 2 days later.
At this point it's clear some members of Congress are either in on this and helping the cover story or they haven't got a clue and are out in the cold.
Note the conflicting stories about 'Rosenstein cancelled meeting with Congress on Oct 11!"
First, rumors surfaced of a scheduled meeting on Oct. 11 between Rosenstein & members of Congress, and Rosenstein just cancelled it.
Rep. Andy Biggs and Rep. Matt Gaetz say DAG Rod Rosenstein cancelled an Oct. 11 appearance before the judiciary and oversight committees. They are now calling for a subpoena. pic.twitter.com/TknVHKjXtd
— Ivan Pentchoukov \U0001f1fa\U0001f1f8 (@IvanPentchoukov) October 10, 2018