You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, I love SWR and I think it's solving the data fetching problem in the most elegant way ❤️
Second, I'm working in a React application that use class components and I would like to use SWR too.
Having a look at the use-swr.ts source file I see that it contains the logic for the hook and the logic to manage the fetching and the cache all together.
Maybe it can be decoupled so we can use SWR out of react hooks context. In my head:
Fetching + catching logic can be taken out to a swr.ts file so anyone could use swr(url, fetch) without hooks.
use-swr.ts would contain only the hook logic and use swr from the point above to get the response for useSWR.
Would you be open to this suggestion? I would give a hand on it if you are interested. I think SWR might be handy outside of react hooks world, even outside react, and a change like this would enable it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there!
First of all, I love SWR and I think it's solving the data fetching problem in the most elegant way ❤️
Second, I'm working in a React application that use class components and I would like to use SWR too.
Having a look at the
use-swr.ts
source file I see that it contains the logic for the hook and the logic to manage the fetching and the cache all together.Maybe it can be decoupled so we can use SWR out of react hooks context. In my head:
swr.ts
file so anyone could useswr(url, fetch)
without hooks.use-swr.ts
would contain only the hook logic and useswr
from the point above to get the response foruseSWR
.Would you be open to this suggestion? I would give a hand on it if you are interested. I think SWR might be handy outside of react hooks world, even outside react, and a change like this would enable it.
Beta Was this translation helpful? Give feedback.
All reactions