How to make use of <Suspense>
I have some code that I think might benefit from the Suspense component.
I understand that for suspense to work the actual component being rendered needs to be asynchronous, but I don't understand how I can make the
OsFolderCard
async as the get_os_folders
function returns all of them at once. If someone could explain how I could do that, or if it's even beneficial or not bcz of the way I fetch my data
1 Reply
To use Suspense you also need to use createResource in some form to load your data - the component shouldn’t be async.
In this case you’ll want to call get_os_folders inside createResource instead of in onMount, and then wherever you read the resource’s data the nearest Suspense will be triggered