DEV Community

Cover image for Vue.js vs. React — Not Your Usual Comparison
Domagoj Vidovic
Domagoj Vidovic

Posted on

Vue.js vs. React — Not Your Usual Comparison

From the moment I started learning React, I completely fell in love with it.

I can create beautiful UIs just with JavaScript? Suddenly, I had the power of JavaScript inside HTML and CSS?

I absolutely loved it. Amazing.

I used the tool for years, but I couldn’t help myself from observing the Vue.js hype. Apparently, every developer that uses it loves it so much!

How’s that possible? I love React, but sometimes it makes me frustrated; why is there much less frustration in the Vue.js world?

I’ve started Vue on a commercial project a few months ago and completely moved from React.

I was a bit sad when I found out that I had moved from my beloved tool.

But those frameworks are just tools; we should never make strict career decisions based on them.

It’s the front-End world — all the tools will vanish soon; new ones will come quickly.

Now, after tons of experience in frontend development and frameworks like Vue.js, React, and Ember.js — let me explain why I find Vue.js the best.

One Really Simple App

We’re building a super simple app in both React and Vue.js today. It looks something like this:

our-really-complex-app

Let’s dive into the code here. React, you come first. This is a project created with create-react-app; I slightly modified App.js here.

import { useState } from 'react';

function App() {
  const [isMagicalAnswerVisible, setIsMagicalAnswerVisible] = useState(false)

  return (
    <div className="App">
      <p className="magicalQuestion">
        Which FE framework is the best?
      </p>
      <button className="magicalButton" onClick={() => setIsMagicalAnswerVisible(true)}>
        Find out!
      </button>
      {isMagicalAnswerVisible && <p className="magicalAnswer">
        .....what is life?
      </p>}
    </div>
  );
}

export default App;
Enter fullscreen mode Exit fullscreen mode

I know React well, so I can understand all of this. But let’s assume I’m don’t know anything about React — only something about FE development and Web in general.

With that knowledge, I want to know what will be rendered on the screen. When I look at the browser, I see only styled HTML elements there. Not JavaScript.

And here — everything is JavaScript! How do I know what will actually render on the screen?

I can see that this function App() returns some code that looks similar to HTML, but it’s not HTML. What is this?

Ok. I’ll assume that thing will render.

What is useState here? Why do need to assign its result to an array immediately?

I don’t care so much about the functionality. I want to see the same thing that I will see on the screen. Why is this strange stuff written first?

What is className? Why can’t I just use class?

onClick={() => setIsMagicalAnswerVisible(true)} why do I have to do this, can’t I just do onClick={setIsMagicalAnswerVisible(true)}? Oh, getting some errors now. I will return the arrow function even though I don’t know why.

{isMagicalAnswerVisible && <p className=”magicalAnswer”>…..what is life?</p>} What is this? What’s with the curly braces? Oh, the JS operator && is here. p will render if that’s true?

Imagine a huge component here. I want to see what I will see on the screen. But I can’t, because I have to scroll the first 100 lines of code to find the return statement.

I trust the naming of the functions. I believe they do what they say. I don’t want to look at the implementation details first.

Let me see what will render!

What Vue.js Has To Offer

This is a project created with the Vue CLI. I modified App.vue here a bit:

<template>
  <p class="magical-question">
    Which FE framework is the best?
  </p>
  <button class="magical-button" @click="findOutMoreAboutThatMagicalFramework">
    Find out!
  </button>
  <p v-if="isMagicalAnswerVisible" class="magical-answer">
    .....what is life?
  </p>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      isMagicalAnswerVisible: false
    }
  },
  methods: {
    findOutMoreAboutThatMagicalFramework() {
      this.isMagicalAnswerVisible = true
    }
  }
}
</script>
Enter fullscreen mode Exit fullscreen mode

Hmm, what can I see here? Oh, the template! I guess I will see this template on the screen.

Oh nice, class is here. Is this an HTML file?

Hmm, here is @click, as well as v-if. A bit strange at first, but actually makes a lot of sense.

And it’s so simple.

The <script> tag is here. Wait, is this really not an HTML file? Should I rename the extension from *.vue to *.html?

Nah, it’s probably fine.

What’s inside the export default here?

data(); what’s this? I’ll need to google it. Oh, it’s just the component’s state.

methods? Pretty straightforward.

I see exactly what will render first. I see something which looks like an HTML.

But it’s not. It’s an extremely powerful Vue.js app.

Vue.js Looks… So Familiar

I want to style my component. What do I need to do?
I’ll assume that it’s the same as in HTML; I’ll just add a <style> tag at the bottom of a *.vue.js file. Nah, that can’t work.

But it works!

The learning curve for React can be huge, especially if you deal with more complex stuff. Remember the times before hooks? So many Render Props, Higher-Order Components, and a bunch of other stuff.

How about this.handleClick = this.handleClick.bind(this)? I know so many React developers who don’t have a clue what’s going on behind the scenes here.

On the other side, everything is so simple with Vue.js. It feels like an updated version of HTML.

I’ve worked so much with Vue.js in the last couple of months, and the amount of frustration is minimal.

I can focus only on the real problem, not the actual implementation.

I wonder all the time — how is that possible? I grasped the core knowledge in 2 weeks, and I can build almost everything now?

It wasn’t like this with React. At times, it was really frustrating. But I still loved it just because it’s all JavaScript.

Everything in JavaScript is Amazing, But It’s Just Not True

The Web is composed out of HTML, CSS, and JavaScript.

If we want to have a deep understanding of it, we mustn’t confuse ourselves with saying that everything is JavaScript.

With Vue.js, I have a feeling that I learn much more general web-related knowledge, not just Vue-related.

With React, it was the opposite. You need to break your deep understanding of the web to adopt that mindset.

The problem is — the web will stay, and React will fade. It’s not a programming language, just a library.

Facebook will release something new; something better.

All your knowledge will vanish with React itself.

Of course, you’re learning a lot of things other than React itself — but with Vue, you’ll learn even more.

Vue works like the web. It’s a bunch of components, looking like the HTML, emitting the events like the real web.

Yes, you don’t pass a function as a prop. You catch a bubbled event that your child component emitted.

Same as in the real web.

Am I overexaggerating?

Ok, I know I am a bit.

Nevertheless, I still love React. Even though I don’t agree with the JavaScript-only web.

But I have a feeling that I can learn the fundamentals better with Vue.

I can focus on the real business problem, not the implementation.

Everything is so simple, yet so powerful.

So fun too, because there’s no frustration.

What do you think about this? I would love to hear something from you.

Latest comments (89)

Collapse
 
anthonybaru profile image
anthony-baru

let's be honest. React much like JQuery is a library, Vue is a fully-fledged framework. In other words, React on itself is fine but when compared to Vue, React is SHIT!!!!

Collapse
 
cdsaenz profile image
Charly S.

The progressive part about Vuejs is totally true. I've been a PHP + "javascript (jquery!) in the browser when necessary" guy - for a long time. So I tried React to see what was all the hype. Ran away in awe. Then found out that I could use Vuejs in the browser. I was able to whip up a dynamic solution, 10 times more elegant than a jQuery alternative in.. no time. Days. But I got something up and running in hours. Without deep knowledge of ES6. After this, I took my time to try out React again.. and it was much easier to grasp. But now I'm studying Vuejs and the CLI. And vite seems interesting. As you said, it's all tools; you may love them but they eventually are replaced. At least with the libraries/frameworks. Choose your favorite color and keep going!

Collapse
 
mavortius profile image
Marcelo Martins

Just an article for Vue's lovers, that's it.

Collapse
 
oniichan profile image
yoquiale

React looks more like a mess compared to Vue, it doesn't even has directives.

Collapse
 
cosmicskull profile image
Cosmic

You are over exaggerated! React is there and it's here to stay don't lie! Don't Diss on react I like it!

Collapse
 
tonylopesdraper profile image
Tony Lopes

I feel the same.

Collapse
 
npongracic profile image
Nebojša Pongračić

I tried both React and Vue and i would choose React over Vue any time of day.
Vue's magical state management is precisely the thing that will bite you in the a** eventually. It works most of the time, but not all. Why isnt it working? Who knows.

Also there are the vue specific attributes you need to learn or resort to React like logic like JSX to do complex stuff.

Not to mention that Vue 3 is really really trying hard to be React so why just not use React?

PS: I don't get how JSX is considered confusing for people who've used HTML, it looks exactly like HTML. You can even use class instead of className and it will work, React will just complain about it.

Collapse
 
domagojvidovic profile image
Domagoj Vidovic

Let’s just hope that more and more companies will adopt Vue! TBH, it would be really hard for me to switch to React now.

Collapse
 
rjitsu profile image
Rishav Jadon

I think that you being an exception, most of the people who have stumbled on to React first and have used it for a period and then used Vue will prefer React more even though yeah Vue is more like the "real web". But the real web is also fading, very few actually make websites with html CSS and js, frameworks and jamstack is used more. And yes React needs more time to set in, but it's worth it. I think it's just preference, wouldn't say one is more better than the other.

Collapse
 
domagojvidovic profile image
Domagoj Vidovic

This article is just my subjective opinion; there’s no clear winner here!

However, HTML, CSS, and JS are still the core of the Web. If we want to understand everything deeply, we can’t ignore them.

Collapse
 
gab profile image
Gabriel Magalhães dos Santos

Probably my comment will sound useless, but everytime this discussion about React and Vue came up, I feel that I have to comment this hahahaha, BUT, The feeling I have coding in Vue that is elegant and fluid, also the tooling are so organized and polished that i have pleasure doing that, in other hand, when i coding React i feel the simplicity of the hooks, but i don't feel like i'm getting all the power from web javascript, in the end is like I'm doing functions who was recalled everytime that component change. TBH I think React is good, but could use more of the web api, and decide at once where it will run, on frontend or backend, this kind of approach could change the mindset of the tool

Collapse
 
gab profile image
Gabriel Magalhães dos Santos

another thing there i forget to mention, vue-cli NEVER give me problems with node-sass because i have the choise to use dart-sass out of the box

Collapse
 
domagojvidovic profile image
Domagoj Vidovic

Elegant and fluid, exactly that! ⚡️

Collapse
 
daveclarke profile image
daveclarke

Good to see opinions being expressed by devs who know both sides of the equation. I'm pretty old school (actually just old) and my first gig was writing Pascal for CTOS. I helped build one of the first internet banking sites in NZ using ASP Classic. Quirksmode was the goto for dealing with IE and Netscape issues, and javascript sucked but it was better than vbscript. The thing that drives me crazy about javascript development now is that maintenance is such a massive issue. Build something now, leave it alone for 12 months, and now all the dependencies have breaking changes. I like Vue because there's less magic than React but the tooling required to develop javascript PWA's is nuts.

Collapse
 
domagojvidovic profile image
Domagoj Vidovic

Wow, you’re on the field for so long, it must feel amazing to see all this progress 🙂

I’m also against magic code so Vue gets a bit plus here

Collapse
 
gchandran profile image
Hemachandran G

Any svelte.js followers here?

Collapse
 
domagojvidovic profile image
Domagoj Vidovic

Many of them - still haven’t tried it properly so I can’t say anything about me!

Collapse
 
jefferson682 profile image
J. Jefferson N. do Vale

congratulations for article! really cool!

Collapse
 
domagojvidovic profile image
Domagoj Vidovic

Glad you like it! Much more coming in the future 🙂

Collapse
 
bonatoc profile image
Christian Bonato

AngularJS was a smart concept from the very start, it was just not so performant and too proprietary.

Quasar Framework shows the true potential of Vue. Not affliated, I am using it for a serious PWA, and it's just mind-blowing how fast you can develop and iterate.

Collapse
 
aaiing profile image
AAI INGENIERIA • Edited

I used Vue and it gave me several problems with its libraries, I am with react and it proves to be a powerful tool that can last for many more years