How do I identify isLoaded? #2754
-
isLoading is not enough isLoading => false-> true-> false
isLoaded => false -> true You can't simulate this yourself, because it's only executed the first time you useHook, and all subsequent useHooks will return the initialization false. const [isLoaded, setIsLoaded] = useState(false)
const { data } = useSWR(
['/api', queryParams],
([url, queryParams]) =>
axios(url, {
params: queryParams,
}),
{
onSuccess: () => {
setIsLoaded(true) //
},
}
) |
Beta Was this translation helpful? Give feedback.
Answered by
vaynevayne
Aug 22, 2023
Replies: 1 comment
-
I think I've figured out that the isLoaded state is not needed. isLoading => true-> false |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
vaynevayne
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think I've figured out that the isLoaded state is not needed.