SolidJSS
SolidJS10mo ago
30 replies
sean

Clarification on createAsync and Suspense behavior

i have an async data which relies on params
id
and offset.

id
is the slug of the page (location.params.id) while offset is just a signal.

the async data is wrapped by a Suspense component with a fallback.

when offset is updated, everything inside the Suspense is re-rendered and a fallback is shown.

however, when
id
changes when navigating, it doesn't seem to re-render - parts of the component are surgically updated - and it doesn't display a fallback.

i'm wondering why is there a difference in behavior in the two? i've always thought that updating a prop that createAsync depends on doesn't cause a re-render - like you have to deliberately do a <Show when={prop} keyed /> to force a re-render

is this because navigation uses a transition? if so, can i employ the same strategy when changing offset?

i've tried with with createAsync and createAsyncStore and both exhibit the same behavior. to avoid triggering Suspense or having a Suspense, am i better off using createResource instead?
Was this page helpful?