From harness-claude
Implements React hooks pattern to extract and reuse stateful logic like data fetching or form state across components using custom hooks with TypeScript typing.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Reuse stateful logic across components via custom hooks
Provides patterns and examples for React Hooks including useState, useEffect, useContext, useMemo, useCallback, and custom hooks for state management and side effects.
Guides writing React hooks with conventions for object returns, SSR safety, state design, effect patterns, cleanup, TypeScript, and performance.
Guides React Hooks usage including useState, useEffect, useContext, useReducer, useMemo, useCallback, custom hooks, and patterns for state, effects, and performance in functional components.
Share bugs, ideas, or general feedback.
Reuse stateful logic across components via custom hooks
use (e.g., useWindowSize, useFetch, useForm).useState, useEffect, useCallback, etc.).useMediaQuery not useEventListener).useEffect.hooks/ directory.// Good: descriptive name, typed return, minimal surface area
function useWindowSize(): { width: number; height: number } {
const [size, setSize] = useState({ width: window.innerWidth, height: window.innerHeight });
useEffect(() => {
const handler = () => setSize({ width: window.innerWidth, height: window.innerHeight });
window.addEventListener('resize', handler);
return () => window.removeEventListener('resize', handler);
}, []);
return size;
}
Custom hooks were introduced in React 16.8 to solve the code reuse problem that previously required higher-order components or render props. The key insight: hooks are just functions, and the use prefix is a convention that enables lint rules (react-hooks/rules-of-hooks) to enforce hook semantics.
Trade-offs:
use naming convention is enforced by ESLint, not the runtime — calling a hook outside a component or another hook will cause runtime errors, not type errorsuse prefix conventionWhen NOT to use:
Related patterns:
useXxx() wrapperhttps://patterns.dev/react/hooks-pattern