Live data from Hacker News

Introducing Hooks

reactjs.org

11–20 of 310 posts

Re: Introducing Hooks

#11
post #7

React is starting to turn from a novel, but essentially simple idea into a clusterfuck mess.

Care to write a substantial contributing comment, or do you intend to keep this random complaint about the simplification of a common pattern in React as shallow as possible?

Edit: No really, I'd like to hear why you think this would make React a "clusterfuck mess" rather than... simpler.

Re: Introducing Hooks

#13
post #8

A demonstration of Hooks is live right now at ReactConf and looks very cool: https://www.youtube.com/watch?v=kz3nVya45uQ (go back about 1.5 hrs into the past to see the start of the demo).

Dan Abramov's talk starts 39 minutes into the livestream: https://www.youtube.com/watch?v=kz3nVya45uQ&t=39m

If you like live coding demos, he also gave a talk at JSConf Iceland where he showed off some future React features, such as asynchronous rendering: https://www.youtube.com/watch?v=nLF0n9SACd4

Re: Introducing Hooks

#14
post #12

Is it just a syntactical difference or is there something more fundamental that I'm missing here?

It's a huge difference, and yet also the same thing.

It's the same concepts of props, state, context, and lifecycle behavior as before.

It's just that now you can do it in function components, not just class components, and the APIs let you handle things without having to have additional levels of wrapper components and without the complexity of class-related gotchas.

Re: Introducing Hooks

#15
"You might be curious how React knows which component useState corresponds to since we’re not passing anything like this back to React. We’ll answer this question and many others in the FAQ section."

While I appreciate the functional usage of state, this type of magical behavior worries me a bit. Wasn't more straightforward semantics possible (even if the syntax wasn't similarly straightforward)?

Re: Introducing Hooks

#16

While I agree that class components has always felt like a workaround to bypass the limitations of function components, and that it's obviously annoying to rewrite a function component to a class component just to add a state or a lifecycle method, the following explanation sounds a bit silly to me: > In our observation, classes are the biggest barrier to learning React. You have to understand how this works in JavaS…

In the live talk, Sophie also discussed how Javascript classes are difficult for machines: minifiers aren't able to shorten the names of methods (because it's apparently hard to work out all the ways that the method could be invoked), and they cause stability problems with hot code reloading. So there are benefits beyond ease of use for humans.

(Also, I'm pretty fluent in Javascript and I still forget to bind event handlers all the time, which suggests to me that it's a counterintuitive pattern even if I know "how it works" on a technical level. And you either have to put a bunch of "this.handler = this.handler.bind(this)" in the constructor, or rely on class properties which are an unstable syntax feature, both of which are suboptimal.)

Re: Introducing Hooks

#17
post #15

"You might be curious how React knows which component useState corresponds to since we’re not passing anything like this back to React. We’ll answer this question and many others in the FAQ section." While I appreciate the functional usage of state, this type of magical behavior worries me a bit. Wasn't more straightforward semantics possible (even if the syntax wasn't similarly straightforward)?

> React assumes that if you call useState many times, you do it in the same order during every render.

Note they also say:

> We provide a linter plugin to enforce these rules automatically.

Makes me feel a little better.

Re: Introducing Hooks

#18
post #7

React is starting to turn from a novel, but essentially simple idea into a clusterfuck mess.

Care to write a substantial contributing comment, or do you intend to keep this random complaint about the simplification of a common pattern in React as shallow as possible? Edit: No really, I'd like to hear why you think this would make React a "clusterfuck mess" rather than... simpler.

I actually agree, this is a mess. This is wildly more complex and confusing than the current state of affairs.
Post reply on HN