Understanding React's useEffect: A Simple Project's Big Impact

Most React developers misunderstand useEffect. I used to be one of them. Whenever something is needed to run after the render… I would just throw it inside useEffect. It worked. But I didn’t really understand why. So I spent the last 2–3 days studying it properly through a small project called Workout Timer. The project itself is simple. It calculates workout duration based on: • workout type • number of sets • workout speed • break duration It also shows a live clock and can play a sound when values change. But the real goal wasn't the timer. The real goal was understanding React behavior and performance. --- While analyzing the project I started questioning everything. Not the code. But the architecture behind the code. Questions like: • Does this really need useEffect? • Is this state actually derived state? • Are my dependency arrays correct? • Could a stale closure break this callback? • Are components re-rendering unnecessarily? --- During this challenge I practiced: • auditing effect dependencies • avoiding effect-driven derived state • fixing stale closures in intervals • stabilizing props for memoized components • verifying cleanup logic for timers • measuring component renders --- One important lesson became very clear: useEffect is not a general-purpose tool. React’s rule is simple: > useEffect exists to synchronize with external systems. Things like: • timers • subscriptions • DOM interactions • browser APIs Everything else usually belongs in render logic. --- This challenge reminded me of something important about learning React. Real improvement doesn't always come from building bigger projects. Sometimes it comes from studying how React actually works under the hood. And this small challenge helped me understand that better. --- I share daily learning posts on Dev.to, while my portfolio contains weekly structured progress recaps. Learning in public. One concept at a time. --- #React #FrontendDevelopment #JavaScript #WebDevelopment #ReactJS #LearningInPublic

To view or add a comment, sign in

Explore content categories