DEV Community

Cover image for What made me use SWR?
Aastha Pandey
Aastha Pandey

Posted on

What made me use SWR?

I have been working on a project which have multiple screens and since I am using react I have to deal with several components but when it came to data fetching it wasn't easy to use the hook called useEffect, I was able to control the useEffect functionalities to some extent using dependency array but the component was mounting and unmounting which made it to refetch the data every single time.
When I learnt about SWR it kind of gave so many functionalities that I could use to control the number of refetches so the first thing I used was, dedupingInterval here I can set the time interval when I need to refetch the data.
Second thing which I used was,
mutate(key): what are the other scenarios I would like to refetch or I can say invalidate the old call.

Top comments (1)

Collapse
 
carrotfarmer profile image
Dhruva Srinivas • Edited

Nice article! Even I was a bit skeptical about using useEffect for my new project