swr
swr copied to clipboard
fix: ensure `revalidateOnFocus` and `revalidateOnReconnect` is work
When using the same hook in multiple places, setting revalidateOnFocus
in one place does not work
In most cases, I want revalidateOnFocus
to be turned off by default (this can avoid too many unnecessary requests). So I disabled it in SWRConfig
. But under certain conditions, I want to enable it (such as a designated tab). Since this hook may be called in multiple places, if only the first hook is checked, the configuration of other components will be invalid.
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 45530d8b47cbf43c057fde4c82c7282db0872085:
Sandbox | Source |
---|---|
SWR-Basic | Configuration |
SWR-States | Configuration |
SWR-Infinite | Configuration |
Yes, it’s missing here, it’s been updated
@u3u would you mind giving an usage example to explain more about this issue? or it would be nice if supplement more information to the description!
@huozhi
In most cases, I want revalidateOnFocus
to be turned off by default (this can avoid too many unnecessary requests). So I disabled it in SWRConfig
. But under certain conditions, I want to enable it (such as a designated tab). Since this hook may be called in multiple places, if only the first hook is checked, the configuration of other components will be invalid.