Skip to content
Discussion options

You must be logged in to vote
  1. I tend to use SWR for everything, but if you know you will never want to update some value, it could make sense to fetch it once, store it in a state and share it through context.

  2. That is common, it's because SWR is revalidating on focus, and if you open your devtool your focus will move between the devtools and your app, so everytime you focus again in the app it will trigger more request, you can disable it with revalidateOnFocus: false.

  3. I think the best way to solve this is to cache the data.

  4. I don't see a reason to do not do it, actually it makes a lot of sense to use SWR to fetch data for a graph, this way your graph will keep up-to-date, what you may want to do is to useMemo…

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@shuding
Comment options

@sergiodxa
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@wanliyunyan
Comment options

@sergiodxa
Comment options

@wanliyunyan
Comment options

@nahasco
Comment options

Answer selected by wanliyunyan
Comment options

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