News for hackers. Stuff that matters.
Re:I love React Hooks by xrd on Wednesday February 20, 2019 @01:33AM (#19206059)
1. Isn't React sort-of magic to begin with?

2. Don't hooks remove the need for redux, etc.? Meaning, don't hooks radically reduce the amount of libraries you need to know about?

3. I prefer to use pure React and not have to choose between Redux, Flux, Mobx etc. And, then do I need to use redux-thunk, etc?

I actually really like the progression towards hooks. I think the articles from the core team (like Dan Abramov) have been well written, explaining not just the how but the why, and it feels like hooks serve to make things simpler and more readable. Yes, you have to throw away a lot of things you spent time learning, but I'm not sad to see anything go away that hooks now handles.

Re:I love React Hooks by Axnyff on Wednesday February 20, 2019 @02:35AM (#19206311)
I feel like if hooks remove the need for redux for you, you actually never needed redux in the first place.
Re:I love React Hooks by omeid2 on Wednesday February 20, 2019 @03:20AM (#19206455)
What Redux brings to the table is separation of Data from Components, it is not uncommon to use the same data point (user profile, user organization/s, et al) in various components. Moving this to component states either requires a lot of prop passing or duplication (api calls!), short of using Context, which is kind of Redux-ish all over again.
Re:I love React Hooks by lioeters on Wednesday February 20, 2019 @04:49PM (#19212354)
> Isn't React sort-of magic to begin with?

That's true, especially JSX caused an uproar in the beginning as "too much magic", and then was gradually accepted as a vast improvement to previous/other ways of templating.

> Don't hooks radically reduce the amount of libraries you need to know?

I'm really hoping so! If they do indeed "serve to make things simpler and more readable", it would be a net positive, regardless of any initial misgivings and possible effort to migrate.

Re:I love React Hooks by rtpg on Wednesday February 20, 2019 @01:41AM (#19206087)
React's core isn't magical insofar as its core functionality (virtual DOM + "update everything on any change") could fit on a 3x5 index card. Implementing it is definitely hard though...
Re:I love React Hooks by baddox on Wednesday February 20, 2019 @02:07AM (#19206187)
Yes. You need “magic” to be able to write and Reason about your programs in a functional style, while still having side effects and state that changes over time. All functional programming environments have this.
Re:I love React Hooks by dnautics on Wednesday February 20, 2019 @03:41AM (#19206535)
I hardly think "not being pure functional" is what the op means by "magic"
Re:I love React Hooks by baddox on Wednesday February 20, 2019 @04:54PM (#19212394)
Perhaps not, but React hooks in my opinion aren't any more magical than the other internals of React that allow you to use a function style to implement component trees that change over time.