← React Intermediate Questions - Set 12 Q119

What are hooks rules in React?

React Intermediate Questions - Set 12

Example

// top level of a component, never inside conditions or loops
function C() {
  const [a] = useState(0);
  if (x) return null;          // early return AFTER all hooks
  useEffect(() => {}, []);     // unreachable: wrong
}

What to notice

← Back to the question list