custom Hook
A React custom Hook extracts reusable stateful logic.
Use this when Components repeat the same subscription, cleanup, or interaction logic.
without the term
“Three components each have the same copy-pasted upload logic with progress, cancel, and cleanup. Can you pull that into one reusable thing?”
with the term · How do you ask a model for custom Hook?
Extract this upload logic into a custom Hook. Verify two independent uploads, cancellation, and cleanup after unmount.
What is custom Hook?
A custom Hook is a function starting with 'use' that wraps reusable stateful logic. Each component that calls it gets its own state unless the Hook subscribes to something shared.
Why does custom Hook matter when vibe coding?
Extracting a Hook does not automatically create one shared state owner.
How do you do custom Hook?
Define the Hook’s inputs and lifecycle, then test multiple consumers and cleanup.
What goes wrong with custom Hook?
Sharing mutable module state unintentionally between Hook consumers.