Am I obliged to combine Suspense with Show?
I get the following error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')
I understand the cause, but I'm surprised. I was expecting that the Suspense
would delay the children until the data is available. Adding a Show
solves the issue, but I'm wondering if I can handle this differently.
10 Replies
In this simplified example, I could use ? instead of !
But in my current issue, I'm using solid-table:
I've never used
createQuery
but if it's protocol is similar to createResource
I'd expect .data
to be undefined
before the first promise settles. If that is the case you should be able to write:
tip: set the initialValue of resource (or whatever the equivalent is for createQuery) and you won’t have to deal with data()?.stuff or <Show>
So Suspense would not be the right tool in this case?
Hmmm true
Most probably tanner thought about that
But I should still use Suspense even with an initial value, right?
you’ll never see the Suspense fallback though
(unless using ssr)
or maybe even not then
idk
ah no
you’ll not see the fallback if you do
data.latest
data()
will trigger fallbackOk ill try that
What I understand is that you choose Suspense or Show but not both
I look at
<Show>
and <Switch>
/ <Match>
as a means of supplying rendering alternatives.
<Suspense>
is more about the paint holding during a transition (marked by unsettled async operations) while rendering the alternate, future branch; the fallback is only relevant in the absence of a transition which often is only the very first time the <Suspense>
sub-tree renders.Chrome for Developers
Paint Holding - reducing the flash of white on same-origin navigati...
A quick overview of paint holding. A Chrome feature for reducing the flash of white on same-origin navigations
Hi @thetarnav, I liked the idea of providing an initial value. With
solid-query
I can either use initialData
or placeholderData
. I choose the latter as it doesn't pollute the cache:
Placeholder data allows a query to behave as if it already has data, similar to the initialData option, but the data is not persisted to the cache. (src: https://tanstack.com/query/v3/docs/framework/react/guides/placeholder-query-data#what-is-placeholder-data)However I'm facing a different problem. When the data is loaded, the DataTable component is not updating the values accordingly I even tried with an intermediary signal (in comment) without success: But this is probably a different question https://discord.com/channels/722131463138705510/1228246382582960199
shouldn’t
createSolidData
take an accessor as one of the params?
either it has some mechanism for handling reactive input
or the whole thing needs to be wrapped in a memoGot my answer on reactivity there
by accessor you mean
get data()
?
I was not aware of this 🙈