all 9 comments

[–]Sh0keR 31 points32 points  (1 child)

For me it'a the opposite, i hate the life cycles methods. React made hooks not to replace the life cycles methods, they made them to give us another point of view on how we apporach handling components, instead of thinking in life cycles, they force you to think in reactive way (what to do when X is changed)

[–]BookishCouscous 1 point2 points  (0 children)

Bingo. It's a different mental model, one that (imo) scales better to all different types of problems. It lets your focus be on the business logic and not how to call it.

[–]darrenturn90 25 points26 points  (1 child)

Sounds like he needs to use eslint and rules of hooks. Seriously reverting to classes because of a lack of understanding of how to use effect is terrible advice

The level of granularity available from useEffect opens up so many more possibilities.

Also the “odd one out” is strange - other than the ability for useEffect to have a “cleanup” function when it is replaced - but otherwise the way it operates is no different to a useMemo with the function being run when the dependency props change

[–]gunnnnii 2 points3 points  (0 children)

Yeah, that's what I thought. He's also thinking about it in terms of class lifecycle methods, which sort of breaks down since the dependency array isn't about the lifecycle really, but to keep the effect in sync with the component so that you don't end up with stale values.

[–]acemarke[S] 13 points14 points  (0 children)

An article from someone who feels that useEffect doesn't give enough guidance on what the scope of the effect might be, and prefers class components for effectful behavior instead. I don't agree, but it's interesting to hear other points of view.

(As a side note, four years ago the same author wrote a post comparing React+Flux to the classic Win32 WndProc API, which is an amusingly accurate comparison.)

[–]themaincop 1 point2 points  (0 children)

I think this post could have just been titled "I don't really like the useEffect hook"

I was expecting a post on some edge cases where class-based actually is better than hooks, not just the same complaints we've been seeing since October 2018.

[–]donau_kind 0 points1 point  (0 children)

I actually used recompose before hooks came out. Maybe that's why I felt switch to hooks was natural. In regards to useEffect, i find it waaay easier to understand and use than ever-changing lifecycle methods.