createAsync vs createResource and how does Suspense work?
Hello. From doing some searches in here it looks like
I am wondering though,
There is the state, the error, and options to mutate and refetch.
But
What if I want to also get the state? What if I want to mutate/refetch the data?
And how should (or how can) I handle errors when using
EDIT: (Answering some of my own questions) since
If I use
Also, I am wondering how Suspense actually works. How does it detect that some data is still loading. Is it possible to create my own resource manually that Suspense detects without using
createAsync (+cache) seems to be the new recommended approach for data loading.I am wondering though,
createResource returns a lot of information and options for the requestThere is the state, the error, and options to mutate and refetch.
But
createAsync returns just the data.What if I want to also get the state? What if I want to mutate/refetch the data?
And how should (or how can) I handle errors when using
createAsync?EDIT: (Answering some of my own questions) since
createAsync returns the data from createResource then it is possible to use data.loading and data.errorIf I use
createResource instead then I won't be able to use cache.Also, I am wondering how Suspense actually works. How does it detect that some data is still loading. Is it possible to create my own resource manually that Suspense detects without using
createResource?