SolidJSS
SolidJSโ€ข17mo agoโ€ข
13 replies
Max

Show Callback with explicit condition

Hi, wondering if possible to use Show with callback and have condition explicity, for example false or undefined, not just any falsy value.

imagine for example

ts
type T = number | undefined

const items: readonly [] = ...
<For each={items} fallback="...">
  {item=><Show when={item===undefined ? false : item}>
    {value=> value}
  </Show>
</For>


For all numbers, including zero, I would like for value to be rendered.

For now I am using Show with no callback and passing boolean to when prop and then a ! non null assertion when using value.

But wondering if maybe there's a smoother way?

Cheers
Was this page helpful?