Fork me on GitHub
Jakub Holý (HolyJak)08:07:58

Question: Why doesn't the state setter from use-state behave like Clojure's update , i.e. having a multi-arity version that takes a-fn and any number of arguments and runs (a-fn current-state args...) ? That way I could replace my (.then (fn [p] (set-state #(assoc % :person p)))) with the simpler (.then (fn [p] (set-state assoc :person p)))) ?


because sometimes I just want to overwrite everything with a literal and not update the state


well, that was a silly answer, you can just set it with this too, sorry


but I like that helix is just a shallow wrapper, maybe a custom hook that you write could do this? I am interested

Jakub Holý (HolyJak)10:07:47

Hm, the docs actually describe this functionality. I have to learn to read the docs fully 😅


was it not working?

Jakub Holý (HolyJak)16:07:27

No, everything is OK. I stopped trading the docs too early :)


I failed on that one, too!