Conditional rendering approach
Hi, it's often the case there is a need to conditionally render components given data that may be undefined.
Given how Solid handles reactivity it seems it is not type safe to use boolean evaluation or ternary statement to conditionally render something. The Show component seems to solve this issue but will only provide a callback to render children of
keyed
is true, I am unsure of the consequences of using keyed. Please see the example below which should illustrate the question fairly clearly.
Thanks, any information would be cool.
https://playground.solidjs.com/anonymous/f6cab1e1-3349-450c-b786-d082187ff209Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
4 Replies
It seems like you've discovered the consequences of keyed: the entire show component rerenders when your variable changes (which is likely not what you want). I'd recommend using something like option 1 with a few exclamation marks to help fix ts.
In a future version we're hoping to make a non keyed show component for ts
Okay cool thanks, so it's a bit like the difference between For and Index for collections yea?
I'll copy this that I'll probably use in case anyone else needs
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Nice thank you I didn't look at stores before. That's cool how it works!