Difference between counter with console.log and rendered display. Console.log lags one behind display state. Use debugger to show why and where the closure is.
This is the stale value problem mentioned in Josh's class: courses.joshwcomeau.com/joy-of-react/03-hooks/05.08-stale-values. To fix this add. // useEffect(()=>{ // console.log("useEffect count:",count) // },[count]) But the point of the video is to demo a debug tool for finding closures.
This is the stale value problem mentioned in Josh's class: courses.joshwcomeau.com/joy-of-react/03-hooks/05.08-stale-values. To fix this add.
// useEffect(()=>{
// console.log("useEffect count:",count)
// },[count])
But the point of the video is to demo a debug tool for finding closures.
Make sure strict mode is off or you will get 2x