-
I looked at the use-query documentation and it says that staleTime defaults to 0. However, the code seems to set staleTime to 1000 when suspense is true. Also, when I run the code below, the query seems to remain fresh for 1 second.
As expected, when the suspense option is true, the default staleTime becomes 1000ms, right? Or it's written somewhere in the documentation, but I didn't see it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
it's an implementation detail, but we cannot default to zero because of how suspense works. suspense unmounts the component and shows the suspense fallback component instead. Then, it re-mounts the component once it's ready. With a staleTime of zero, this would lead to another refetch, which is unwanted. The small staleTime prevents this. |
Beta Was this translation helpful? Give feedback.
it's an implementation detail, but we cannot default to zero because of how suspense works. suspense unmounts the component and shows the suspense fallback component instead. Then, it re-mounts the component once it's ready. With a staleTime of zero, this would lead to another refetch, which is unwanted. The small staleTime prevents this.