Call hooks only at the top level
Do not call hooks in conditions, loops, or nested functions.
// ✅
function MyComponent() {
const [count, setCount] = useState(0);
// ...
}
// ❌
if (condition) {
useEffect(() => {});
}React relies on consistent hook call order across renders.