S
SolidJS•2y ago
bigmistqke

losing reactivity in For component

example repo: https://playground.solidjs.com/anonymous/b106963a-0ea6-4da2-a066-8bbf42bfc1f0 why is todo.nested.data not updated when i set the store?
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
19 Replies
REEEEE
REEEEE•2y ago
if you wrap todo.nested.data in a fragment it works
<For each={store.tests}>
{(todo) => <>{todo.nested.data}</> }
</For>
<For each={store.tests}>
{(todo) => <>{todo.nested.data}</> }
</For>
bigmistqke
bigmistqkeOP•2y ago
o damn thanks that was really breaking my brain that's quite unexpected behavior!
REEEEE
REEEEE•2y ago
yeah you can also do
<For each={store.tests}>
{(todo) => () => todo.nested.data}
</For>
<For each={store.tests}>
{(todo) => () => todo.nested.data}
</For>
bigmistqke
bigmistqkeOP•2y ago
mm ye but that's dangerous if ur gonna put it in a component
bigmistqke
bigmistqkeOP•2y ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
bigmistqke
bigmistqkeOP•2y ago
mount everest
REEEEE
REEEEE•2y ago
If it's a component you dont have to
bigmistqke
bigmistqkeOP•2y ago
i wonder if For should just wrap anything in a fragment just in case 🤔
REEEEE
REEEEE•2y ago
ehh I think it's by design
bigmistqke
bigmistqkeOP•2y ago
or if string | number then in case there is overhead o really what could be the purpose? sort of implicit untrack?
REEEEE
REEEEE•2y ago
I would think so I think it expects a function for the reactivity to come into play but I can't really speak to specifics because I'm not deeply familiar with it myself It's just how I understand it
bigmistqke
bigmistqkeOP•2y ago
a fragment is a function? wonder where on discord i could ask more about this
REEEEE
REEEEE•2y ago
okay this might be completely wrong so take it with a grain of salt, but I think all elements are technically functions when they get handled by solid
bigmistqke
bigmistqkeOP•2y ago
maybe in docs?
REEEEE
REEEEE•2y ago
hmmm maybe in #reactivity
bigmistqke
bigmistqkeOP•2y ago
a ja lol that makes more sense
REEEEE
REEEEE•2y ago
ryan seems to be posting some stuff so maybe he'll be able to take a look and explain it I would also love a better understanding of it
bigmistqke
bigmistqkeOP•2y ago
o ye they seem to be having a good discussion over there, gonna post it a bit later not to break their flow 🙂
lxsmnsyc
lxsmnsyc•2y ago
a function returning an element is a valid element see JSX.Element type definitions
Want results from more Discord servers?
Add your server