Help Me Solve "undefined" warning When Using <Show> Component
I'm using
createAsync()
to get and order record.
order
has the following type:
const order: Accessor<Order | undefined>
Because order
could be undefined, I must check for that in my jsx.
I'm trying to do that with <Show when={order()}>
I thought adding the when={order()}
would return false if order()
was undefined, and satisfy typescript, but typescript is still complaining with this message:
So, how can I get rid of this "undefined" error?
I'm trying to do this "the solid way," and I can't figure it out.
I get the undefined error when trying to pass the order
to a component like this:
<OrderTable order={order} />
Here's the full component for context.
2 Replies
Use the callback form of
Show
to get the narrowed version of order()
as a new signal
That worked like a charm!
Thank you!
You just solved a big headache. I'll be adding this to my notes.
Have a great night.