Closed martinpengellyphillips closed 4 months ago
I think it has to do with order of operations, the ??
is higher than ? ... : ...
, and so the line
return <>{meta.highlight ?? item.id === 2 ? 'PEAR' : item.name}</>;
is same as
return <>{(meta.highlight ?? item.id === 2) ? 'PEAR' : item.name}</>;
and because meta.highlight
is always truthy, it immediately jumps to 'PEAR'
to fix this, try using parenthesis different way
return <>{meta.highlight ?? (item.id === 2 ? 'PEAR' : item.name)}</>;
Indeed! Thanks for the hint. Closing this as user error :)
Describe the bug
When a nullish coalescing operator is used with an additional ternary check within a
<For>
loop, Solid appears to render a duplicate and incorrect value for every item.Your Example Website or App
https://playground.solidjs.com/anonymous/8888fdd6-3c51-43ad-a7c8-18f26f57574c
Steps to Reproduce the Bug or Issue
Expected behavior
List should output the same with nullish coalescing operator as with using multiple ternary operators.
Screenshots or Videos
Platform
Additional context
No response