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
Hm, the docs actually describe this functionality. I have to learn to read the docs fully 😅
😄
me too
@holyjak it does
was it not working?
No, everything is OK. I stopped trading the docs too early :)
I failed on that one, too!