-
Task: Observe the
console.logs:- Hit the
Dispatch (copy)button 3 times - Hit the
Dispatch (mutation)button - Observe the
console.logstatements
Do the log statements make sense to you?
- Hit the
-
Make entire fetch function into a
useReducerfunction -
Issues: This CodeSandBox
-
Problem:
stepcauses too frequent set/clear interval calls!stepunrelated to interval. How to remove it? -
Tricky: Updater function optimization already present..
-
Exercise: Start with CodeSandBox: this to implement reducer function
-
Note:
useStateis implemented withuseReducerusing abasicStateReducer. So all things we learned aboutuseStatealso apply here. -
useReduceruses the Object.is comparison operator.