Replies: 2 comments
-
Hey, is it okay to open a PR about this? 😅 |
Beta Was this translation helpful? Give feedback.
0 replies
-
@rikutiira can you share what you did to patch this? |
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
-
Currently if you call the same
useSWR
hook twice (e.g. when component re-renders), the returned response is not the same reference as what the previous call returned even though nothing has changed. Using the returned response with hooks such asuseEffect
,useMemo
oruseCallback
will therefore cause unnecessary computations to happen.I would like to open a PR to update
useSWR
anduseSWRInfinite
to return the same response reference if nothing has changed, which is as simple as wrapping the returned response object inuseMemo
call.I temporarily patched SWR for our project but hopefully this could be merged to SWR soon as it's a very quick and small fix.
Beta Was this translation helpful? Give feedback.
All reactions