Mid
From PDF
React
React.js
Only call hooks at the top level?
Short answer: (Don’t call hooks inside loops, conditions, or nested functions.)
Real-world example (ShopNest)
ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png