3 ms·
Personally, what I love about React is how simple the model is. There are no Directives or Filter or whatever else. It's just a Component with a state, a render
by d0m 10y ago
Personally, what I love about React is how simple the model is. There are no Directives or Filter or whatever else. It's just a Component with a state, a render and some life cycle methods. That's it. The full power of Javascript in a render function. The second you try to move away from the "full power of javacript to render your view", the more you need to add special cases in your template engine.
Just randomly going through the Vue docs, we see stuff like:
>> Note that you should not use an arrow function with the data property (e.g. data: () => { return { a: this.myProp }}). The reason is arrow functions bind the parent context, so this will not be the Vue instance as you expect and this.myProp will be undefined.
I don't want to deal with this crap anymore. I'm still making nightmares about $scope.$apply. (Yes I know Vue doesn't have the $apply problem, that was just an example).
Where I think Vue.js really shine is for teams that want a standard, industry proven solution, to build web apps. Similar to Angular, you don't have to re-invent the wheel. You just look in the documentation and use whatever is built for you. I think this is great for many projects. Personally I've been burned by the limitations of those frameworks and I'd rather keep my freedom to build things the way I want.
In the Vue comparison, they say this is how you build components with React:
render () {
let { items } = this.props
let children
if (items.length > 0) {
children = (
<ul>
{items.map(item =>
<li key={item.id}>{item.name}</li>
)}
</ul>
)
} else {
children = <p>No items found.</p>
}
return (
<div className='list-container'>
{children}
</div>
)
}
If you're the kind of person who keep repeating that kind of code everywhere in your app, then yes, maybe Vue.js is better for you. But such if/else pattern is easily abstracted away with a simple function which makes it as concise as the Vue snippet without relying on directives in templates. Also, keep in mind that this is only one use case. What if it needs to be slightly more complex? WIth Vue/Angular, you're forced to add directives or whatnot. With React, same render function. I like that cognitive simplicity. Yeah, maybe the render function is slightly more complex, but at least there's only that to be aware of. Not hundreds of directive/filters/whatnot spread everywhere.
In a way, I feel like React is more lower level. I use it to build my own framework on top of it. Where I feel like Vuejs, similar to Angular, is the framework.