#How to set a new value in a store of `Record<string, __>`?

9 messages · Page 1 of 1 (latest)

subtle summit
#

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:

Uncaught TypeError: Cannot read properties of undefined (reading 'output')

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?

quasi monolith
subtle summit
#

oh nice

#

should I give produce a priority?

#

or rather, is one method more optimized than the other?

quasi monolith
#

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

onyx ledge