dont-use-use-effect

Installation
SKILL.md

Don't Use useEffect

useEffect is one of the most misused hooks in React. In the vast majority of cases where developers reach for it, there is a simpler, more performant, and more correct alternative. Every unnecessary useEffect introduces an extra render cycle, increases the risk of bugs (stale closures, race conditions, infinite loops), and makes components harder to reason about.

The golden rule: Effects are for synchronizing with external systems (DOM APIs, timers, websockets, third-party widgets). If the work you're doing is a response to a user event, or can be calculated from existing state/props, you don't need an Effect.


1. Derived State — Just Calculate It

The most common useEffect anti-pattern: storing a value in state that can be computed from other state or props.

// 🔴 BAD: Redundant state + unnecessary Effect
function Form() {
  const [firstName, setFirstName] = useState('Taylor');
  const [lastName, setLastName] = useState('Swift');
  const [fullName, setFullName] = useState('');
Related skills
Installs
59
Repository
jonmumm/skills
GitHub Stars
2
First Seen
Mar 5, 2026