DEV Community

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

Posted on

5 1

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

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay