Why I Chose Vue over React

Why I Chose Vue over React

We made a comparison of Angular, React and Vue by building a small web application using each. That concluded with React

Why I Chose Vue over React

In my last article, we made a comparison of Angular, React and Vue by building a small web application using each. That concluded with React and Vue being the champion.

In this article, I would like to share my views on why I have become a big fan of Vue. I will try to be unbiased as much as possible. So, this in my own opinionated take on the question. Here’s why.

List elements

One of the most common element in a web app is to render a list element given an array. Let’s see the syntax in Vue and React.

React

<ul>
  {
    dataArray.map(data,i)=> <li key={i}>{data}</li>)
  }
</ul>

react-list.js

Vue

<ul>
	<li v-for="(data,i) in data" :key="i">
		{{data}}
	</li>
</ul>

vue-list.js

Now which looks more simpler, React’s jsx syntax or Vue’s html, you decide. 
I prefer the cleaner vue’s syntax.

Component Skeleton Structure

Below is the basic component syntax written in both.

class myComponent extends Component{
	constructor(){
		this.state = {
			data:['Mango','Grapes','Guava']
		}
	}
	render(){
		const { data } = this.state;
		return <ul>
		{
			data.map((data,i) =>
				<li key={i}>
					{data}
				</li>
			)
		}
		</ul>
	}
}

react-component.js

<template>
	<ul>
		<li v-for="(data,i) in data" :key="i">
			{{data}}
		</li>
	</ul>
</template>

<script>
	export default {
		data:()=>({
			data:["Mango","Grapes","Guava"]
		})
	}
</script>

vue-component.js

Writing components should be simple with clear distinction in javascript part and html. Things look mixed up in react’s syntax (again completely my opinion).

Component Lifecycles

In React we have

  • constructor
  • componentWillMount
  • componentDidMount
  • componentWillUpdate
  • componentDidUpdate
  • render

Distinguishing between each of them becomes quite confusing for a newbie and i don’t blame them. Sheer number of lifecycles is a bit too much. Now in which lifecycle should we do an api call for fetching data.

In Vue we have

  • created
  • mounted
  • updated
  • beforeCreate
  • beforeMount
  • beforeUpdate

Simple enough and all of them make sense. Most often we have to deal with created or mounted lifecycle.

Event handling

Event handling should be very simple and straight forward since it is one of the most used feature of any javascript framework. Lets see how React and Vue handle this.

class myComponent extends Component{
	constructor(){
		this.state = {
			data:['Mango','Grapes','Guava']
		}
		this.handleClick = this.handleClick.bind(this);
	}
	handleClick(){
		console.log('list clicked')
	}

	render(){
		const { data } = this.state;
		return <ul onClick={this.handleClick}>
		{
			data.map((data,i) =>
				<li key={i}>
					{data}
				</li>
			)
		}
		</ul>
	}
}

react-event.js

<template>
	<ul @click="handleClick">
		<li v-for="(data,i) in data" :key="i">
			{{data}}
		</li>
	</ul>
</template>

<script>
	export default {
		data:()=>({
			data:["Mango","Grapes","Guava"]
		}),
		methods:{
			handleClick(){
				console.log('list clicked')
			}
		}
	}
</script>

vue-event.js

Vue provides very simple syntax for handling events where as in react, using this keyword then binding this in constructor seems unnecessary for a simple click handler.

Computed properties

Before wrapping, i would like to highlight one of the awesome feature that vue provides, computed property.

Lets say we have a prop called, dollars and we have to render converted rupees in ui. This becomes very simple with computed property. Below is how we’ll use it

<template>
	<span>{{dollar}}$ in Rupees is ₹{{rupees}}</span>
</template>

<script>
	export default {
		props:{
			dollar:Number
		},
		computed:{
			rupees(){
				return this.dollar * 68;
			}
		}
	}
</script>

vue-compute.js

In my opinion, Vue is simpler than other current frameworks and thus makes the learning process easier not overwhelming. Hope you liked the article. If you did, please share a clap. Please feel free to suggest your own insights! Thanks for reading…

Tip: Easily share UI components across apps

Use Bit (open source) to easily share and manage reusable components between apps and projects- to build fatser! Give it a try:

Learn more

Vue.js 2 Academy: Learn Vue Step by Step

Vue.js 2 Essentials: Build Your First Vue App

Nuxt: Supercharged Vue JS

Vue.js Fast Crash Course

Vue JS 2: From Beginner to Professional (includes Vuex)

What are the differences between the various JavaScript frameworks? E.g. Vue.js, Angular.js, React.js

What are the differences? Do they each have specific use contexts?

What are the differences? Do they each have specific use contexts?

Top Vue.js Developers in USA

Top Vue.js Developers in USA

Vue.js is an extensively popular JavaScript framework with which you can create powerful as well as interactive interfaces. Vue.js is the best framework when it comes to building a single web and mobile apps.

We, at HireFullStackDeveloperIndia, implement the right strategic approach to offer a wide variety through customized Vue.js development services to suit your requirements at most competitive prices.

Vue.js is an open-source JavaScript framework that is incredibly progressive and adoptive and majorly used to build a breathtaking user interface. Vue.js is efficient to create advanced web page applications.

Vue.js gets its strength from the flexible JavaScript library to build an enthralling user interface. As the core of Vue.js is concentrated which provides a variety of interactive components for the web and gives real-time implementation. It gives freedom to developers by giving fluidity and eases the integration process with existing projects and other libraries that enables to structure of a highly customizable application.

Vue.js is a scalable framework with a robust in-build stack that can extend itself to operate apps of any proportion. Moreover, vue.js is the best framework to seamlessly create astonishing single-page applications.

Our Vue.js developers have gained tremendous expertise by delivering services to clients worldwide over multiple industries in the area of front-end development. Our adept developers are experts in Vue development and can provide the best value-added user interfaces and web apps.

We assure our clients to have a prime user interface that reaches end-users and target the audience with the exceptional user experience across a variety of devices and platforms. Our expert team of developers serves your business to move ahead on the path of success, where your enterprise can have an advantage over others.

Here are some key benefits that you can avail when you decide to hire vue.js developers in USA from HireFullStackDeveloperIndia:

  • A team of Vue.js developers of your choice
  • 100% guaranteed client satisfaction
  • Integrity and Transparency
  • Free no-obligation quote
  • Portal development solutions
  • Interactive Dashboards over a wide array of devices
  • Vue.js music and video streaming apps
  • Flexible engagement model
  • A free project manager with your team
  • 24*7 communication with your preferred means

If you are looking to hire React Native developers in USA, then choosing HireFullStackDeveloperIndia would be the best as we offer some of the best talents when it comes to Vue.js.