Member-only story

You probably don’t need that useEffect in your React app

A hard look at React’s most misunderstood feature

Chanon Roy
3 min readNov 11, 2023

After many years of PR reviews for React code, my most common feedback is the same timeless phrase: “You probably don’t need that useEffect”. Like many other override patterns in software, useEffect gives us an escape hatch for when we need to go against the core principle of what React encourages. In today’s post we’ll examine React’s core principle to better understand how and when this tooling should be used.

The core principle of React

At its core, React provides us a declarative method to render user interfaces, meaning that you describe what you want to achieve without specifying how to do it step by step. The virtual DOM is the secret sauce that allows React to performantly render the missing pieces when state changes. This was a huge departure from the highly imperative way that UI development worked with tools like jQuery to manually change the DOM in response to state changes.

React was inspired by Facebook’s Flux architectural pattern for building client-side apps, which focuses on having data flow declaratively in one direction. This provides a clear and predictable structure for understanding where data is coming from.

--

--

Chanon Roy
Chanon Roy

Written by Chanon Roy

🧑🏻‍💻 I write about tech and programming. I'm also fluent in film references

Responses (1)