This content originally appeared on DEV Community and was authored by Aastha Pandey
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.
This content originally appeared on DEV Community and was authored by Aastha Pandey
Aastha Pandey | Sciencx (2021-05-12T09:59:57+00:00) What made me use SWR?. Retrieved from https://www.scien.cx/2021/05/12/what-made-me-use-swr/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.