Questions & deep dives
The JavaScript gotchas that trip people up in interviews. Browse by topic or search by title.


How to get previous value in useEffect in React
React functional components do not expose previous values directly within useEffect. To compare current and prior values, developers should persist values between renders using useRef. This approach enables precise change detection, efficient side-effect control, and predictable component behavior.
Feb 21, 2026