Fork me on GitHub
#helix
<
2020-07-06
>
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)))) ?

6
Aron09:07:08

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

Aron09:07:38

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

Aron09:07:03

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 😅

lilactown16:07:48

was it not working?

Jakub Holý (HolyJak)16:07:27

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

ordnungswidrig19:07:12

I failed on that one, too!