Hacker News new | ask | show | jobs
by dabernathy89 2453 days ago
I wouldn't argue that hooks is a simpler programming model, except perhaps under the hood. The Hooks API is not intuitive. I'm sure once you get a hang of it it's not hard, but as a Vue developer reading Hooks code it's not very clear.

While there was some backlash to the initial Hooks-inspired style in Vue, they went back to the drawing board and came up with a better way to explain it to the community that has gotten a much better response. I also find Vue's API for "hooks" much more intuitive/readable than React hooks, because it maps pretty well to the old style of writing code.

1 comments

I have trained a dozen or so developers on React and for less experienced developers, hooks are much more intuitive because they don't rely on an abstract understanding of arbitrary lifecycle identifiers, instead, hooks are explicitly executed in application code that is logically accessible to the programmer.
I have a hard time seeing how lifecycle identifiers could be called "arbitrary" except perhaps (again) from an "under the hood" viewpoint. From an API standpoint they are explicit and extremely simple.

I don't have anything against hooks except the API. There is no way for someone who isn't intimate with the ecosystem to understand the difference between these:

    useEffect(() => {
      document.title = foo;
    }, [foo]);



    useEffect(() => {
      document.title = foo;
    });


    useEffect(() => {
      document.title = foo;
    }, []);
Whereas anyone can understand `componentDidUpdate`, `componentDidMount`, `componentWillUnmount` just by reading them.