How to set a new value in a store of `Record<string, __>`?
In the following example:
https://playground.solidjs.com/anonymous/07b233f7-59cb-4202-a3ca-595a497912f8
setValue("abc", 3)
on a blank object will trigger an error:
Probably because the internal of the Store's path syntax function is trying to access the data.
Am I suppose to use the Immer inspired produce
to add a new element to an object, or is there a syntax I don't know to use directly the setter from the store without using produce
?Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
5 Replies
You could do this if you don't want to use produce
https://playground.solidjs.com/anonymous/c8811330-19f7-4243-8c45-0f721abf194a
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
oh nice
which one is better ?
It seems for arrays suggestion are made in the doc (https://docs.solidjs.com/guides/complex-state-management#adding-to-an-array) but not for object
should I give produce a priority?
or rather, is one method more optimized than the other?
It could be that the syntax isn't supported internally for object but it is for arrays
If you're going to do "complex" changes, I would just use produce
How is it supposed to now what to set
input
to?
i.e. input
isn't marked as optional.yes it was a reduced and incomplete example to illustrate my situation 😉