Escape Suspense when using resources?

Is there any way to escape supsense when using createResources? or am i pretty much "doomed" once i have one suspense boundary at the top of the tree? What i mean by "escape" is to not trigger the suspense to fall back. Playground: https://playground.solidjs.com/anonymous/1a49076e-e6b1-4577-962d-3098c3263eea The only way i can think of is with transitions (like in that playground). But once those are used, the "loading" or "status" props are no longer useable and i'd instead have to wrap the "pending" signal of the transition hook i think? Is there an easier way to escape? Also i am not really sure how i would go about wrapping a resource in a transition if i want it to immediately fetch (vs. after an interaction like in the example. Looking at the third "options" param nothing sounds like it would do it. https://deploy-preview-360--solid-docs.netlify.app/reference/basic-reactivity/create-resource Thanks
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
9 Replies
lxsmnsyc
lxsmnsyc5mo ago
add another Suspense boundary, closest to where you access your resource data there's no "escape" since createResource and Suspense are dependent to one another
KamehamehaNudel
KamehamehaNudel5mo ago
Hmm I thought, createResource was also kinda the goto convenience wrapper to „get prromises“ into signals For context: I had a geolocation request wrapped and on interaction request it from the user. But I kinda don’t want that to reset the whole layout but just have a „pending“ on the button createeffect is my friend I suppose
lxsmnsyc
lxsmnsyc5mo ago
it is, and Suspense is the UI manager for it there's a lot more going on in the internals but the shallow detail is createResource and Suspense rely on one another
KamehamehaNudel
KamehamehaNudel5mo ago
hmm i guess i have to restructure the markup a bit then
lxsmnsyc
lxsmnsyc5mo ago
if you aren't relying on the data to be resolved by the promise then createEffect is fine
KamehamehaNudel
KamehamehaNudel5mo ago
Thanks for the answers. I'll try to wrap my head around it But tbh right now i still don't really get why i cannot "get back" the behavior of the resource as if there were no suspense. i kinda just put the <suspense> at the top of the tree without much though since all router examples had it 😅
lxsmnsyc
lxsmnsyc5mo ago
that's just the fallback, but don't rely on it. It's required to put a Suspense boundary as close to the data access
KamehamehaNudel
KamehamehaNudel5mo ago
yeah what i was trying to achieve is something like. "from this point on stop caring about suspense again and just be undefined" idk maybe my whole approach i had is flawed
Samual 🦢
Samual 🦢3mo ago
I had to do this to avoid suspense for a specific resource:
const [ foo ] = createResource(
() => {
// ...
},
async bar => {
// ...
}
)

const getFoo = createMemo(() => foo.loading ? undefined : foo())
const [ foo ] = createResource(
() => {
// ...
},
async bar => {
// ...
}
)

const getFoo = createMemo(() => foo.loading ? undefined : foo())
and then use getFoo() instead of foo directly
Want results from more Discord servers?
Add your server
More Posts
Circular references in Stores?Hi again, Solid community! Coming with another new person question 🙂 Is it possible to have circulHow to make a library with Vite's library mode?I'm in a monorepo scenario and want to make a component library for the shared UI. Since there's notUnderstanding memoization re-runningHi everyone, I'm new to SolidJS (from React), but so far enjoying it! I was running into some unexpMake sure your app is wrapped in a <Router />Hey folks, probably something silly but why can't I access `useNavigator` in my RouteGuard? AttachiFailed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted...We are facing this rather flakey error when upgrading to the new Solid Start Beta 0.4. Failed to exDownload file from public/documentsHi, I want to have an A-Element, that starts a download for a .pdf-file I placed in public/documentHaving trouble implementing a stack of views because of the lifecycle of <Dynamic>For my site, I have implemented a stack of views, sort of like on iOS where you can push and pop vieUse solid as middlewareGoal: parse existing html from third party server, read all data-component attributes from HTML, loaHow to trigger createEffect when navigating to the same URL ?Hi, is it possible to trigger a createEffect that listens to location.search from the solid router'sGetting ReferenceError: React is not defined with Vitest + Solid Testing LibraryI honestly have no idea how I am receiving this error but I am despite testing using `@solidjs/testi