React hooks - useState, useEffect, and custom hooks

4311
0

React Hooks enable state and lifecycle features in function components. I use useState to add stateful values that persist between renders. The useEffect hook handles side effects like data fetching, subscriptions, and DOM manipulation. Dependencies array controls when effects run - empty [] means run once on mount. Custom hooks extract reusable logic by composing built-in hooks. The useCallback hook memoizes functions, while useMemo memoizes values. The useRef hook creates mutable references that persist across renders. The useContext hook accesses context without prop drilling. Hooks must follow rules: call at top level, only in function components.