S
SolidJS•3y 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•3y 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•3y ago
o damn thanks that was really breaking my brain that's quite unexpected behavior!
REEEEE
REEEEE•3y 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•3y ago
mm ye but that's dangerous if ur gonna put it in a component
bigmistqke
bigmistqkeOP•3y ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
bigmistqke
bigmistqkeOP•3y ago
mount everest
REEEEE
REEEEE•3y ago
If it's a component you dont have to
bigmistqke
bigmistqkeOP•3y ago
i wonder if For should just wrap anything in a fragment just in case 🤔
REEEEE
REEEEE•3y ago
ehh I think it's by design
bigmistqke
bigmistqkeOP•3y ago
or if string | number then in case there is overhead o really what could be the purpose? sort of implicit untrack?
REEEEE
REEEEE•3y 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•3y ago
a fragment is a function? wonder where on discord i could ask more about this
REEEEE
REEEEE•3y 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•3y ago
maybe in docs?
REEEEE
REEEEE•3y ago
hmmm maybe in #reactivity
bigmistqke
bigmistqkeOP•3y ago
a ja lol that makes more sense
REEEEE
REEEEE•3y 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•3y 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•3y ago
a function returning an element is a valid element see JSX.Element type definitions
Want results from more Discord servers?
Add your server