3 ms·
Having used React commercially for around five years and Vue for two and I don't feed this article really hits the mark. The two biggest difference between the
by Rodeoclash 6y ago
Having used React commercially for around five years and Vue for two and I don't feed this article really hits the mark.
The two biggest difference between them I've noticed is that Vue has been more "batteries included". The Vue authors have made all the choices (and integrations) around routers, state management etc for you. If you like the decisions they've made then that's great, if you don't then you might find yourself using less polished libraries.
The other is what I think has lead to Vue's popularity, that is, it allows you to get away with more and not in a good way. React makes it quite hard to deviate from their model of doing things. I.e. state flows down via props and back up via callbacks. However, with Vue, it's quite possible for components to know (and interact) with their parent components directly, i.e. call methods on them, modify internal state. This makes it easy to get things going but leads to all sorts spaghetti code down the track. React does its best to stop this kind of behaviour.
In summary, Vue has gained traction not only from it batteries included approach (and being novel) but also because it allows you less frustration when developing and doesn't try to stop you from writing terrible code like React does.
- stickfigure 6y ago> know (and interact) with their parent components directly Do you have that backwards, or is there something I'm missing? In React it's easy for child components to interact with their parents by calling callbacks. What's hard is to call methods on children and interact with their state... the answer is always "lift state up".
- Rodeoclash 6y agoThat's correct. However in Vue I have access to $this.parent which is an instance of the parent component. My child component can read data directly from it, even modify state of the parent by reassigning values.
- jnwr 6y agoImportant note here is using $parent is bad form and discouraged in the vue docs[0] 0. https://vuejs.org/v2/style-guide/#Implicit-parent-child-communication-use-with-caution https://vuejs.org/v2/style-guide/#Implicit-parent-child-comm...