Live data from Hacker News

With React 16.8, React Hooks are available in a stable release

reactjs.org

21–30 of 181 posts

Re: With React 16.8, React Hooks are available in a stable release

#21
Something that I really like about React is that it is easy to reason about the state of each component, with functions there was no state, with classes, you can see everything that touches the state there in your class.

I am not sure how having various functions (hooks) that trigger state changes and so re-rendering is going to pan-out in practice.

Here comes setInterval and counter packages, no I don't believe I can simply avoid using them, everyone depended on leftpad, indirectly.

Re: With React 16.8, React Hooks are available in a stable release

#22
post #21

Something that I really like about React is that it is easy to reason about the state of each component, with functions there was no state, with classes, you can see everything that touches the state there in your class. I am not sure how having various functions (hooks) that trigger state changes and so re-rendering is going to pan-out in practice. Here comes setInterval and counter packages, no I don't believe I ca…

There is a blogpost from dan abramov about using setInterval with hooks: https://overreacted.io/making-setinterval-declarative-with-r...

Re: With React 16.8, React Hooks are available in a stable release

#23
post #10

Earlier quoted context omitted.

I've been working with hooks for quite a while now; its main benefit is composability - before hooks up you rely on Higher order components (HOCs, HOFs but in component rendering) to provide composability of component behaviour - this is messy, very messy, and not performant. By using hooks the logic tidies up massively (so working on it becomes a lot quicker) and several hard to diagnose performance bottlenecks disa…

Can you please give some example of behaviour that you share across components that couldn't be factored out into a function?

Well they can, except that function needs state as a parameter or calls from lifecycle, which means changing many places inside the component to have that state as well as call that component.

A HOC previously served as a minimally invasive way to compose these behaviours (compose the HOC + use its param in render).

If you are writing a moderately complex animation, you can quickly end up needing state, willMount, and willUnmount, plus the render change plus the logic, thats five places in a class. If this animation applies to many components you abstract to a HOC and simplify dev overhead at a performance cost.

Using a hook lets you abstract that all into one function as you suggest.

Most of the HOCs I wrote had to do with just local state + store state + logic, so not as extreme (editable, updatable, draggable, deletable etc.); but when you have many, the penalty adds up.

Re: With React 16.8, React Hooks are available in a stable release

#24
post #21

Something that I really like about React is that it is easy to reason about the state of each component, with functions there was no state, with classes, you can see everything that touches the state there in your class. I am not sure how having various functions (hooks) that trigger state changes and so re-rendering is going to pan-out in practice. Here comes setInterval and counter packages, no I don't believe I ca…

There is a blogpost from dan abramov about using setInterval with hooks: https://overreacted.io/making-setinterval-declarative-with-r...

[deleted]

Re: With React 16.8, React Hooks are available in a stable release

#25
Are hooks being accepted as a good design by the community?

It seems to me that the lack of a parameter explicitly indicating the component and the reliance on hook ordering to match them across calls of the component function make them a bad design, but I might very well wrong and would be happy to be convinced otherwise.

Re: With React 16.8, React Hooks are available in a stable release

#26
post #16

Earlier quoted context omitted.

A variation on Elm? Why not just Elm?

Well, he said "the next frontier". Probably implies that Elm didn't catch on, and means "what will the next major framework/paradigm/fad will be post-React".

I honestly don't think that there will be another framework that'll overtake react anytime soon. It's not about there being a better framework, just that we finally have something that's "good enough".

Re: With React 16.8, React Hooks are available in a stable release

#27
post #25

Are hooks being accepted as a good design by the community? It seems to me that the lack of a parameter explicitly indicating the component and the reliance on hook ordering to match them across calls of the component function make them a bad design, but I might very well wrong and would be happy to be convinced otherwise.

My impression is the community is mostly accepting, but some are taking a wait and see attitude until they can see it in production.

I don't think there's a lot of concern about hook ordering; it's hard to see that being a serious issue in practice. And it has some significant advantages over existing alternatives.

Re: With React 16.8, React Hooks are available in a stable release

#28
post #26
post #16

Earlier quoted context omitted.

Well, he said "the next frontier". Probably implies that Elm didn't catch on, and means "what will the next major framework/paradigm/fad will be post-React".

I honestly don't think that there will be another framework that'll overtake react anytime soon. It's not about there being a better framework, just that we finally have something that's "good enough".

True. I used ExtJS and Ember for years and React just operates on another level.

Re: With React 16.8, React Hooks are available in a stable release

#30
post #25

Are hooks being accepted as a good design by the community? It seems to me that the lack of a parameter explicitly indicating the component and the reliance on hook ordering to match them across calls of the component function make them a bad design, but I might very well wrong and would be happy to be convinced otherwise.

This talk introducing hooks explains it well: https://youtu.be/V-QO-KO90iQ:
Post reply on HN