what's the drawback of abusing swr as a client side global storage? #2167
Unanswered
aboveyunhai
asked this question in
Q&A
Replies: 1 comment
-
I've pondered the same, but never built a demo to play with the idea. Hypothetical performance issues aside, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Not really seeking for advices because I wouldn't do that in real project, and just suddenly came up this idea.
but wonder what would happen if I don't use SWR as "data fetching" but as react
useContext()
, what problem it might cause?The reason I asked that it's because
useContext()
will cause the entire sub-tree re-render if you don't memoize them. Abusing SWR can somehow achieve the same effect without that problem. Of cuz, all similar behaviors are only possible aftermutate
was introduced.Also the abusing example: https://codesandbox.io/s/morning-tdd-4o1fkb?file=/src/index.js
Beta Was this translation helpful? Give feedback.
All reactions