News for hackers. Stuff that matters.
Re:Metaphysics and JavaScript by _bxg1 on Wednesday September 04, 2019 @04:42PM (#20881215)
This is a very good take. DOM as a function of state has real tradeoffs but also real benefits; state as a function of state just gets out of hand. IMO React Hooks are where React jumped the shark. setState and Redux were already clunky and felt too rooted in unhelpful ideals, but hooks just took the cake.

My company's codebase uses MobX for all state and I highly recommend it. It embraces mutability and imperative code where they make sense: in your actual app state. React is there to do what it's best at: rendering DOM. That's it. Rendering remains functional and real, meaningful state is allowed to be what it is.

Re:Metaphysics and JavaScript by lioeters on Friday September 06, 2019 @09:50AM (#20895604)
Glad to see there's a vocal minority who disagree with the way React Hooks are implemented. I raised my objections when it was announced (even got super kind feedback from Dan Abramov himself) - but it was too late, they "jumped the shark", as you put it. I looked up the meaning of the phrase, not sure it's totally suitable for this situation - but I feel that React crossed a threshold with its release.

I started considering alternative view libraries from that point, and continued to resist against using Hooks in my own React-based projects. The thing is, I love how React transformed web development, it's got huge mind share in the community, and there's nothing better out there yet. I just wish it had stayed small and simple, kept other concerns out of it and focused on doing its one thing only.

Re:Metaphysics and JavaScript by Tade0 on Wednesday September 04, 2019 @04:52PM (#20881296)
To add insult to injury it's fairly easy to use hooks wrong - and used wrong they are, which suggests that their learning curve is not as friendly as proponents of this pattern would wish.
Re:Metaphysics and JavaScript by nezygis on Thursday September 05, 2019 @02:36AM (#20884374)
Could you share some examples of hooks used wrongly in code?
Re:Metaphysics and JavaScript by Tade0 on Thursday September 05, 2019 @07:47AM (#20885727)
useCallback used as something else than a provider of callback functions, e.g. for rendering.

Example:

  const renderItem = useCallback(() => <Item />, []);
And then:

  return renderItem();
What should have been used here is useMemo.