react useEffect pattern: ref previous

Photo by Maksym Kaharlytskyi on Unsplash

Problem