Hasty Briefsbeta

Bilingual

Why Isn’t X a Hook? — overreacted

13 hours ago
  • React Hooks include useState(), useEffect(), and useContext(), but not all APIs are Hooks.
  • Key properties for Hook APIs are composition (custom Hooks should not conflict) and debugging (easy bug tracing).
  • useState() supports composition and debugging by allowing independent state variables and clear cause-effect paths.
  • A proposed useBailout() Hook fails because it breaks composition by blocking updates from other Hooks and complicates debugging by hiding the source of skipped updates.
  • React provides useMemo() instead of a Hook version of memo() to avoid composition and debugging issues.
  • Other APIs like useProvider(), useCatch(), or useSuspense() are not Hooks due to similar composition and debugging constraints.