Resetting state in child component
I have a form that takes default values as a prop. But the default values can change when a different dataset is selected in the parent, in which case I want to reset the form state and provide new default values. In React, you could use
key
for this, but that doesn't exist in Solid. Is there another solution?4 Replies
Nice, that works! Thank you
If you don't mind, can you explain what this actually does?
well first any expression that you put between
{}
in JSX will be "wrapped in a function" by solid and called in like a memo or other computation.
And ()
is just a weird js syntax where you can have combine multiple expressions, and return only the last one
so it's kinda like writing an iife
fyi there's also a component in
solid-primitives
that does this if you want a "cleaner-looking" solution