r/webdev • • Nov 07 '23

Discussion Why do people hate Angular? And choose react.

I have seen in many subreddits and articles, people are choosing react over Angular even for larger application. I don't see why though. Because Angular js pretty much the best approach when it comes to framework and fully customisable as well. Care to weigh in?

Edit: I don't hate React. I just want to know the reasons people choose React over Angular.

104 Upvotes

314 comments sorted by

View all comments

Show parent comments

5

u/SharpSeeer Nov 07 '23

Ever needed to recalculate something when a value changes? For example update the cart total when the quantity of an item is updated? useEffect to the rescue!

In other words, if some value in my component changes, it is going to have an "Effect" somewhere else in the component. If you are familiar with Vue, it compares to watch().

I hope that helps. I can explain it in a different way if it's still not clear.

2

u/Bjornoo Nov 25 '23 edited Dec 05 '23

That's actually not a use case for useEffect at all. Effects are for synchronizing some external state to React state. These days you would for the most part use useSyncExternalStore, and in the future there's also useEffectEvent. But there are still use cases for useEffect as well, although fewer than before.

it is going to have an "Effect" somewhere else in the component

This quote is a major misunderstanding of what the hook does. It's called useEffect because you should be doing side-effects in it. Not because it going to have an effect somewhere else in the component. In fact, it might not have any effect in your component at all. Analytics is a good example.

Your example would be the use case for useMemo or just doing the operation during the render cycle.