Extract reusable stateful logic into custom hooks. Rules of hooks and when to create your own.
Sometimes you want to reuse stateful logic (state + effects + handlers) across components. Copy-pasting useState and useEffect is messy. Custom hooks are the answer: a function whose name starts with use and that calls other hooks.
They don’t add new capabilities — they compose existing hooks. Examples: useWindowWidth(), useLocalStorage(key), useDebounce(value, delay), useFetch(url).