antipattern
A common way of solving a problem that looks reasonable but causes bugs or extra work.
In more detail
Antipatterns are worth naming so teams recognise and avoid them. Each has a known better alternative.
Example
Typical React antipatterns are syncing state with an Effect, calling hooks conditionally, using array indexes as keys and mutating props.Related terms
- derived state — A value that can be calculated from existing props or state, so it should be computed during render instead of stored as separate state.
- Rules of Hooks — The two rules for hooks: call them only at the top level, never in conditions, loops or nested functions, and only from React components or custom hooks.
- index as key — Using an item position in an array as its React key, which breaks when items are inserted, deleted or reordered.
Taught in
- useEffect Lifecycle: Mount, Dependencies, And Cleanup Phases — React 19 & Modern Component Architecture
- Avoiding Effect Antipatterns: Derived State And Events — React 19 & Modern Component Architecture
- useRef Mechanics: DOM References And Mutable Persistent State — React 19 & Modern Component Architecture
- Rules of Hooks: Call Order, Hook Lists, And Fiber Storage — React 19 & Modern Component Architecture