Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You've misspelled the handler, onClick is the correct casing. Fix that and it works.

Also you don't need to use a ref -- if I were inclined I could have grabbed the element by a query selector. I'm not sure why I would though, as I mentioned using ref is better protection against DOM updates.

> In order to declaratively wire things up in an idiomatic way in React, we've had to introduce a bunch of React APIs

Yes, because declarative programming is the benefit not the cost. As I said, you don't have to do it declaratively -- you can always use built-in DOM APIs -- but most people in the front-end community have agreed that doing things declaratively and architecting a UI as a state machine instead of a giant tree of independently mutating bits is preferable.

One of the biggest sources of bugs in jQuery projects is developers forgetting to keep the DOM in sync with the data. The benefit of doing things declaratively is you don't have to worry about it. Cutting that problem off at the source is an invaluable benefit.



He knows. He's the author of https://mithril.js.org/.

It's a person well-steeped in the theory and benefits of declarative and functional programming taking a step back and looking at the supposed enemy with fresh eyes and a deeper perspective.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: