useSWRConfig mutate function causes to request data from the api twice #2488
Unanswered
yyuurreecc5
asked this question in
Q&A
Replies: 2 comments 2 replies
-
In this case, you don't have to pass |
Beta Was this translation helpful? Give feedback.
0 replies
-
But, then we return to the previous issue: |
Beta Was this translation helpful? Give feedback.
2 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.
-
Bug report
Description / Observed Behavior
When I'm calling mutate function from useSWRConfig hook the api request is called twice.
Expected Behavior
I expect it will be called only once after mutate function is called
Repro Steps / Code Example
CodeSandbox
When show === true (component mounted). The api request is executed twice on one click of the revalidate button (why?). And isValidating flag changes on true only when second api request is starting. It behavior is repeated on every click.
When show === false (component unmounted). After click on the revalidate button apiRequest is executed despite the fact that there is not a single mounted component using swr on page. Is this behavior correct?
Additional Context
SWR version: 2.1.0
Beta Was this translation helpful? Give feedback.
All reactions