DefaultConfig of useSWR should not be overwritten with undefined #2570
Unanswered
kazukinagata
asked this question in
Ideas
Replies: 1 comment
-
@kazukinagata What is the expected output for |
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
-
We have a custom hook called useUsers that wraps useSWR as follows. This hook accepts the revalidateIfStale SWR option, with a default value of undefined.
I expected that
defaultConfig.revalidateIfStale /** this is true **/
would be applied when I passed an empty object to useUsers. However, the config.revalidateIfStale was merged with mergeObjects as undefined, which was contrary to my expectations.You can find the code here:
swr/_internal/utils/helper.ts
Line 22 in 342b82c
Is this the intended behavior?
I would like to suggest the following implementation to avoid overwriting defaultConfig when the user passes undefined.
Beta Was this translation helpful? Give feedback.
All reactions