S
SolidJS8mo ago
Davide

computations created outside a `createRoot` or `render` will never be disposed

I have an onClick event that updates a store, and immediately after, it reads a derived value that depends on the store value. It works correctly, the derived value updates immediately before reading it, but since the derived state produces JSX, I am getting the above error. If I instead don't produce JSX I don't get the error. Ive been having a hard time understanding what is happening and what that error means in this context. Could somebody help me?
4 Replies
Grahf
Grahf8mo ago
I'm curious what the event handler looks like. Does it have a createEffect in it?
lxsmnsyc
lxsmnsyc8mo ago
I would assume you're passing JSX around, which is not a pattern I'd encourage specially since it produces some behavior like the error you're experiencing
Davide
Davide8mo ago
Yeah I figured, but what I’m wondering is why? In react it’s pretty normal to have functions return jsx and pass that around
lxsmnsyc
lxsmnsyc8mo ago
well because Solid has no VDOM so basically it's instanciating everything where JSX is declared. JSX in React of course is just a bunch of POJO so it doesn't do anything