Is createAsync supposed to work with Suspense?
My Suspense component is not working well with createAsync. Basically, anything iside the Suspense block is running even though the promise from createAsync hasn't finished.
I've got a fairly simple setup that's failing and I'd love to understand if this is by design and expected, or something that I'm doing wrong, or a bug:
Simple SolidJS app with Solid Router. No SSR, no SolidStart. Classic component routing. The result is an uncaught error stating result() is undefined...
Any ideas?
4 Replies
This is because result() is undefined until the promise resolves
The children of suspense actually run right away even if it holds to show the fallback
Better do it with <Show> or <Switch/Match> component
But as soon as your app has at least one <Suspense> wrapped, then any resource reading will trigger the nearest<Suspense>
i.e.
Thank you so much @peerreynders @TaQuanMinhLong and @TaQuanMinhLong ! This has been enlightening!