Amy Blankenship
Feb 20, 2025

--

Senior developers actually know that the useEffect cleanup runs whenever the dependencies in the dependency array change. If you don't provide any dependencies, everything in the useEffect, including the cleanup function, will run on every render. The cleanup for the useEffect will run when the code inside the _next_ render of the useEffect runs.

This is actually why React is kind of a crappy framework, because it leads people into thinking they know what's going on. And 95% of React developers have no clue. Even ones who think they're senior.

--

--

Amy Blankenship
Amy Blankenship

Written by Amy Blankenship

Full Stack developer at fintech company. I mainly write about React, Javascript, Typescript, and testing.

Responses (1)