Re:Thinking in React Hooks
by dhucerbin on Thursday December 12, 2019 @02:32PM
(#21775407)
To be fair, reagent uses it's own implementation that satisfy atom protocol. And it uses some funky magic with keeping derefs and triggering rerenders. In principle, as atom is idiomatic Clojure, setState is idiomatic javascript. ratoms and hooks both add some sugar to it.
[ Parent
| on HN ]
`setState(...)` is not idiomatic in JavaScript.
I'm not sure how far back you want to go, but `this.set` is used in most frontend frameworks, starting around knockout and backbone. You had object which managed state for you (then it was model, today it is component) and it had some setter method.