What are React hooks and what are the rules of hooks?
Hooks are functions that let function components use React features such as state (useState), side effects (useEffect), context (useContext) and refs (useRef). There are two rules: call hooks only at the top level of a component or custom hook — never inside loops, conditions or nested functions — and call them only from React function components or other hooks.