-
Task: Observe the
console.log
s:- Hit the
Dispatch (copy)
button 3 times - Hit the
Dispatch (mutation)
button - Observe the
console.log
statements
Do the log statements make sense to you?
- Hit the
-
Make entire fetch function into a
useReducer
function -
Issues: This CodeSandBox
-
Problem:
step
causes too frequent set/clear interval calls!step
unrelated to interval. How to remove it? -
Tricky: Updater function optimization already present..
-
Exercise: Start with CodeSandBox: this to implement reducer function
-
Note:
useState
is implemented withuseReducer
using abasicStateReducer
. So all things we learned aboutuseState
also apply here. -
useReducer
uses the Object.is comparison operator.