React & Modern Frontend (445 Qs)•Part 9: React Hooks Deep Dive (262 - 316)
Can you have multiple useEffect hooks in a single component?
Yes, multiple useEffect hooks are allowed and recommended when you want to separate concerns.
jsx
useEffect(() => {
// Handles API fetch
}, []);
useEffect(() => {
// Handles event listeners
}, []);
Each effect runs independently and helps make code modular and easier to debug.