Live data from Hacker News

Introducing Hooks

reactjs.org

1–10 of 310 posts

Re: Introducing Hooks

#2
Cool idea, feels a bit like observables, especially the unsunscription via returned callback.

The call order thing seems odd. Don't know how to sell this to people.

Re: Introducing Hooks

#4
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 JavaScript, which is very different from how it works in most languages. You have to remember to bind the event handlers. Without unstable syntax proposals, the code is very verbose. People can understand props, state, and top-down data flow perfectly well but still struggle with classes. The distinction between function and class components in React and when to use each one leads to disagreements even between experienced React developers.

A framework shouldn't be designed around the fact that people don't know the language they are using, right?

Anyway, those hooks look like a good way to solve the issues listed above. Can't wait to try it out!

Re: Introducing Hooks

#5
This is interesting. I'll have to spend some time mulling over this before the benefits sink in. It seems like a much more confusing and less composable API than recompose, which is how I add state, lifecycle, and other React class features to functional components. I've been completely avoiding React classes for a while now and using stateless components with recompose for over a year now, and I find it to be a wonderful architecture for component testability and reusability.

https://github.com/acdlite/recompose/blob/master/docs/API.md

Re: Introducing Hooks

#6

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…

At the end of the day, the framework that allows people to get more done with less thought is going to win the most mindshare.

Re: Introducing Hooks

#9

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…

To be fair, JavaScript has been a moving target and things like classes are quite new. Then again, it doesn't make sense to avoid features just because they're new.

I think the point is that they want to provide two ways to do simple things: classes and functions. Functions have better performance, classes are more flexible.

Re: Introducing Hooks

#10
post #5

This is interesting. I'll have to spend some time mulling over this before the benefits sink in. It seems like a much more confusing and less composable API than recompose, which is how I add state, lifecycle, and other React class features to functional components. I've been completely avoiding React classes for a while now and using stateless components with recompose for over a year now, and I find it to be a wond…

Right but with recompose you get extra wrapping components in your tree which is what they were trying to avoid.
Post reply on HN