DEV Community

Discussion on: Debouncing with React Hooks

Collapse
 
jamison_dance profile image
Jamison Dance

You wrap side effects in useEffect so they don't run on every render. You technically could make a request inside render without wrapping it in useEffect, but it'll happen on every single render, which is usually not what you want.

You typically only want side effects to run when things they care about change, like when some search text changes. That's exactly what useEffect does for you - it helps make sure the side effects only run when they need to.

Thread Thread
 
raulmarindev profile image
Raúl Marín

This reply is great, thanks!