Full stack development

Stage 2 · Lesson 5 of 8

Effects, and when you do not need one

Git, npm and React

An keeps a in step with something outside , such as a timer, a browser API or a subscription. You write one with useEffect. It runs after the component renders.

It runs again when a value in its array changes. Its cleanup function runs before the next run and when the component is removed. In you need far fewer effects than older React tutorials suggest.

Initial data is usually fetched in a server component instead. And values you can calculate from props or state should be calculated during render. Reach for an effect only when you truly need to sync with the outside world.

Common trapThe common traps are a missing dependency, which leaves you with a stale old value, and setting state inside an effect that depends on that same state, which loops forever.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • GuideFree
    React Documentation

    Meta

    Free official course; Thinking in React and Managing State matter most

  • CourseFree
    Next.js Learn

    Vercel · Intermediate

    Free official course: the first chapters build pages, layouts and navigation

Practise

Keep handy

Mark this stage as not done?