In this lesson we look at a common beginner mistake when using state provided by hooks in React. It applies to useState, useReducer, Redux, Zustand, Valtio and probably any other state manager that uses hooks.
The cause: stale values in closures.
Code On Github: https://github.com/basarat/demo-state-callback
-- Part of ReactJS TIPs for Professionals --
Members (no-ads 🌹, early release ⚡️, supported by you 🙏🏻): https://www.youtube.com/playlist?list=PLYvdvJlnTOjGX3hezMwMQWy29j7xMVg5h
Subscribers (free 🤗, scheduled release ⏱, use the notification bell 🔔):https://www.youtube.com/playlist?list=PLYvdvJlnTOjHZEkICYcz_pV2SUD80YQ6J
👇 ❤️ Subscribe for MOORE ❤️ 👇https://www.youtube.com/basaratali?sub_confirmation=1
🌹 Support 🌹