hookstate icon indicating copy to clipboard operation
hookstate copied to clipboard

The initial is mutated

Open vbuch opened this issue 2 years ago • 1 comments

When a state is created, one could pass in an inital value. If that initial value is an object, it is later mutated when calling set or merge.

Repro: https://codepen.io/vbuch/pen/BaxzeZY?editors=0011

I'm fine with just having this documented. But it took me quite some time to figure where my data gets messed up.

vbuch avatar Sep 12 '22 13:09 vbuch

yes, hookstate works on mutable object

avkonst avatar Sep 13 '22 11:09 avkonst

documented in concepts https://hookstate.js.org/docs/getting-started

avkonst avatar Dec 19 '22 01:12 avkonst