News for hackers. Stuff that matters.
Re:Vue RFC: Expose logic-related component options via funct... by pier25 on Thursday June 20, 2019 @06:14PM (#20237930)
Yes, that's what the React team should have done when they implemented hooks.
Re:Vue RFC: Expose logic-related component options via funct... by NewsAware on Thursday June 20, 2019 @06:27PM (#20238037)
Well, with React you can "opt in" when searching by simply adding "hooks" to the search term. Such wasn't possible with Angular back then
Re:Vue RFC: Expose logic-related component options via funct... by pier25 on Thursday June 20, 2019 @06:43PM (#20238136)
Since the majority of the community will probably be using hooks from now on it will be assumed that is the default React methodology which will break books, talks, blog posts, SO answers, etc.
Re:Vue RFC: Expose logic-related component options via funct... by ng12 on Thursday June 20, 2019 @06:52PM (#20238211)
You can mix-and-match. If you want to write an individual component as a class you can, and if you want to later convert it to using hooks there's nothing stopping you.
Re:Vue RFC: Expose logic-related component options via funct... by pier25 on Thursday June 20, 2019 @07:03PM (#20238295)
That's not the point.

The point is that most of the React literature available today will become obsolete.

Re:Vue RFC: Expose logic-related component options via funct... by ng12 on Thursday June 20, 2019 @07:04PM (#20238299)
How? It's still perfectly valid, usable, idiomatic React.
Re:Vue RFC: Expose logic-related component options via funct... by pier25 on Thursday June 20, 2019 @07:17PM (#20238401)
If you learned React with hooks the class notation won't make sense, and viceversa.
Re:Vue RFC: Expose logic-related component options via funct... by ng12 on Thursday June 20, 2019 @07:18PM (#20238415)
So they should have renamed the whole framework when they added a single a new feature so people know they need to learn it before reading the examples?
Re:Vue RFC: Expose logic-related component options via funct... by pier25 on Thursday June 20, 2019 @07:57PM (#20238666)
It's not a new feature it's a complete new methodology.
Re:Vue RFC: Expose logic-related component options via funct... by root_axis on Thursday June 20, 2019 @08:43PM (#20238890)
The point is that you don't have to use it. If you can't be bothered to learn a simple new feature then just keep doing it the old way; your code will still work. I don't even understand the complaint; are they never supposed to change anything? It's totally optional; even if most of the community goes down that direction you don't have to.

Beyond that, hooks are super simple and the complainers are just making a big deal out of nothing. They are just callback functions that you implement outside of a class instead of overloading arbitrary method identifiers like "componentDidUpdate".

You also don't have to use it.

Re:Vue RFC: Expose logic-related component options via funct... by ng12 on Thursday June 20, 2019 @08:42PM (#20238881)
That's quite hyperbolic. Functional components have existed in React for a long time, hooks are just adding existing concepts (state and lifecycle operations) to them.
Re:Vue RFC: Expose logic-related component options via funct... by pier25 on Friday June 21, 2019 @10:42AM (#20242880)
We will have to agree to disagree. IMO the compositional paradigm of hooks is radically different than using classes for example.
Re:Vue RFC: Expose logic-related component options via funct... by BigJono on Thursday June 20, 2019 @07:40PM (#20238557)
This is what I don't get about hooks. Remembering Markbages great talk on 'Minimal API Surface Area'? How is having multiple ways of doing the same thing minimal API surface area?

React is losing sight of what made it great when it came out. Do one thing, do it well, and do it the simplest way possible.

Re:Vue RFC: Expose logic-related component options via funct... by thatswrong0 on Thursday June 20, 2019 @08:08PM (#20238728)
That sort of absolutist logic will never allow a framework to progress and become better. Sometimes good ideas come around (IMO like hooks) that are worth increasing the API surface area for.

I for one loathe using class components now and not being able to share logic compositionally via hooks when I work with them. I feel more productive and I feel like my components are smaller and more focused, and I don’t repeat myself as much. It’s been a net win for me, and I think it’s well worth having two supported APIs that do roughly the same thing.. because despite this, React is still a small and focused library API-wise.

Re:Vue RFC: Expose logic-related component options via funct... by ng12 on Thursday June 20, 2019 @08:43PM (#20238889)
They've increase the surface to reduce it over time, if that makes sense. Hooks are much more natural, simplistic way to write stateful components.
Re:Vue RFC: Expose logic-related component options via funct... by zwily on Thursday June 20, 2019 @06:25PM (#20238018)
Why? Hooks are completely backwards compatible.
Re:Vue RFC: Expose logic-related component options via funct... by pier25 on Thursday June 20, 2019 @06:41PM (#20238120)
What about books, talks, blog posts, SO answers, etc?

Is everyone going to rewrite all React literature with hooks?

Re:Vue RFC: Expose logic-related component options via funct... by pests on Thursday June 20, 2019 @08:31PM (#20238811)
No rewriting needed. Hooks are just another way to do what was already possible in a more well-defined way. All the content written is still applicable. Now there is just a new way to do things too.

The developers and documentation even advises against rewriting old components with hooks unless you need to.

Re:Vue RFC: Expose logic-related component options via funct... by pier25 on Thursday June 20, 2019 @09:07PM (#20239005)
> All the content written is still applicable.

Technically yes, but what if someone only uses hooks and has never used classes?

And, viceversa, since there is now a lot of people moving to hooks and producing React literature for hooks what if you only have used classes?

So now, to be able to read all the React literature one has to understand both methodologies.

> The developers and documentation even advises against rewriting old components with hooks unless you need to.

It doesn't matter. A big chunk of the JS community is hype-based.

Re:Vue RFC: Expose logic-related component options via funct... by pests on Saturday June 22, 2019 @07:23PM (#20252289)
You're gonna have to learn it eventually to work with other code bases and so on. But the point was it doesn't change existing knowledge, just something new to learn.
Re:Vue RFC: Expose logic-related component options via funct... by fourthark on Friday June 21, 2019 @12:59AM (#20239978)
So don't listen?
Re:Vue RFC: Expose logic-related component options via funct... by ng12 on Thursday June 20, 2019 @06:26PM (#20238029)
Hooks are additive.