Skip to content
Discussion options

You must be logged in to vote

@rolznz
SWR has a compare option to customize a comparison function to avoid unnecessary re-renders by useSWR.
https://swr.vercel.app/docs/options#options

But in your case, I think it's best to use React.memo to solve it because it's a matter of each element, so the compare option wouldn't help the case.

If you don't want to re-render a component that uses useSWR, the compare option might be your help.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rolznz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants