react-errors-hooks
Installation
SKILL.md
react-errors-hooks
Quick Reference: Error Diagnostic Table
| Symptom | Cause | Fix |
|---|---|---|
React has detected a change in the order of Hooks |
Conditional hook call or early return before hooks | Move ALL hooks above any conditional logic or returns |
Invalid hook call |
Hook called in regular function, class, or nested scope | ONLY call hooks from function components or custom hooks |
Too many re-renders |
setState called during render body |
Move state update into event handler or useEffect |
| Component re-renders infinitely with useEffect | Missing dependency array or new object/array in deps | Add [] deps, destructure objects to primitives, or use useMemo |
| State shows old value in setTimeout/setInterval | Stale closure captures initial state value | Use functional updater setState(prev => ...) or useRef |
| State shows old value in event listener | Event listener closed over stale state | Use useRef to hold latest value, or re-register listener |
Warning: Can't perform a React state update on unmounted component |
Async callback updates state after unmount | Return cleanup function from useEffect with ignore flag |
React Hook useEffect has a missing dependency |
eslint-plugin-react-hooks exhaustive-deps violation | Add the dependency, move code into effect, or restructure |
React Hook "useX" is called conditionally |
Hook inside if/else, loop, or after early return | Restructure to call hook unconditionally at top level |
React Hook "useX" cannot be called in a class component |
Hook used inside a class component | Convert to function component or extract hook logic |
| Effect fires twice in development | StrictMode double-invocation (expected behavior) | Ensure cleanup function properly reverses setup |
useFormStatus always returns pending: false |
Hook called in same component as <form> |
Move useFormStatus into a child component rendered inside the form |