Live data from Hacker News

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

reactjs.org

101–110 of 181 posts

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

#101
post #48

Earlier quoted context omitted.

> It's basically the magic vs explicit discussion all over again. Like usually in this discussion, the magic approach is really appealing until it doesn't work, and then the pro-explicit people will go all "told you so" on you. Well... Have any "pro-explicit people" gone all "told you so" about all the magic that's going on with setState? I don't think so. I don't think it's a binary magic vs explicit choice. I usual…

What's wrong with setstate? I have used it without problem.

Apparently nothing, but from how I read it a lot of magic is going on underneath the covers (which I cannot really imagine, if react is as simple as it claims).

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

#102
post #56
post #41

Earlier quoted context omitted.

Hooks offers nothing new over HoC and FaC the same way React offered nothing new over jQuery and EmberJS.

That is being unfair to React. React changed the way developers reason about UI/DOM from imperative to declarative, the holy grail here is that a declarative API allows you to move up your state and have a "single source of truth" and so makes it easy to reason about your application's state at the cost of having more plumbing, for example consider incriminating the value of an input with jQuery (imperative) vs React…

You misunderstood the parent.

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

#103

I am stealing this thread as it seems to have a lot of really knowledgable people in here. I understand basic javascript but I am not an expert and I had a discussion with a developer I want to hire for a new app I am doing, who said that there is no open source components (like quill) which easily allow you to have textformating (bulleted lists, bold, text size etc) and that it would have to be done from scratch) wh…

The official tutorial would be a good starting point:

https://reactjs.org/tutorial/tutorial.html

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

#104
One thing I can’t figure out in hooks vs recompose is how to use them and avoid props drilling or even just basic wiring. One of the most glorious things about recompose is that the props are drilled/wired for you automatically. This turns out to be huge for me. I had so much tedious props drilling code that just went away with recompose. Anyone have any insight?

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

#105

I've read a lot about hooks, the reasoning all makes sense but I'm still not fully getting it at an intuitive level. Like I get that it means you can write functional versions of class based components, an example of a complex class component that has been converted to a function with hooks would be good. The counter example really leaves a lot to the imagination. The examples in https://usehooks.com/ aren't convinci…

It's a little harder to wrap your head around for sure.

But the benefit is tighter encapsulation of functionalities. No longer do we have to spread a feature's logic across multiple lifecycle methods that may share that space with logic from other features.

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

#106
post #48

Earlier quoted context omitted.

> It's basically the magic vs explicit discussion all over again. Like usually in this discussion, the magic approach is really appealing until it doesn't work, and then the pro-explicit people will go all "told you so" on you. Well... Have any "pro-explicit people" gone all "told you so" about all the magic that's going on with setState? I don't think so. I don't think it's a binary magic vs explicit choice. I usual…

What's wrong with setstate? I have used it without problem.

There's nothing wrong with `setState`, in my opinion. However, it does do magic. Although it might feel like it immediately sets the state to be what you provide it as argument, it actually schedules a state update to be performed later when React feels like it. That's why it's best practice to provide an updated function rather than a plain object: if the new state depends on the previous one, and you read the previous state before calling `setState`, then that can lead to problematic behaviour.

(And of course, there's the magic of the returned object not being set as the new state, but rather being merged into the previous one.)

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

#107
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.

While HN wasn’t convinced last time I posted this, here’s a few posts or sections that explain the static call order thing: https://overreacted.io/why-do-hooks-rely-on-call-order/ https://overreacted.io/react-as-a-ui-runtime/#static-use-ord... https://github.com/reactjs/rfcs/pull/68#issuecomment-4393148... (Persistent Call Index section) Hope this helps, happy to answer questions. We’ve been using Hooks for several m…

One thing that looks 'magical' is how does the setWhatever function lets React know that state has changed and has to re-render? Is there any info/writeup on this anywhere?

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

#108

Hooks seem to be a drastic change in how we're going to write React components in the future. I'm quite satisfied with the current way of writing components which is to me is very explicit (with no magic). With Hooks React is taking a different direction from their original motto of explicit design patterns. From the looks of it, Hooks seems like a counter-intuitive design pattern but traditionally that's how most of…

Maybe you just don’t understand them yet.

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

#109

Hooks seem to be a drastic change in how we're going to write React components in the future. I'm quite satisfied with the current way of writing components which is to me is very explicit (with no magic). With Hooks React is taking a different direction from their original motto of explicit design patterns. From the looks of it, Hooks seems like a counter-intuitive design pattern but traditionally that's how most of…

In case you’re curious, I recently wrote up a deep dive on React from first principles that includes Hooks. https://overreacted.io/react-as-a-ui-runtime/ Personally I don’t see them as being either “magic” or “implicit”. You might find my post helpful for conceptualizing how they fit into the picture. (Warning: it is a longread. But it also explains 90% of React on a single page.)

Thanks for writing this. Really enjoy your writing style and hope you continue to write more!

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

#110

Earlier quoted context omitted.

While HN wasn’t convinced last time I posted this, here’s a few posts or sections that explain the static call order thing: https://overreacted.io/why-do-hooks-rely-on-call-order/ https://overreacted.io/react-as-a-ui-runtime/#static-use-ord... https://github.com/reactjs/rfcs/pull/68#issuecomment-4393148... (Persistent Call Index section) Hope this helps, happy to answer questions. We’ve been using Hooks for several m…

One thing that looks 'magical' is how does the setWhatever function lets React know that state has changed and has to re-render? Is there any info/writeup on this anywhere?

The component renders any time the setWhatever function is called, similar to this.setState() in class components. The presumption is anything that you're storing in state is depended on by the component. If it's not, it doesn't make sense to have it in state anyway.
Post reply on HN