Live data from Hacker News

Switching From React To Vue.js

vuejsdevelopers.com

21–30 of 186 posts

Re: Switching From React To Vue.js

#21
> ... If message is passed as a prop to any child components, Vue knows that they depend on this will be automatically re-rendered as well. That’s why there’s no need for a shouldComponentUpdate method on Vue components.

I think that React does the same? If a component's props and state don't change, shouldComponentUpdate doesn't get called at all IIRC. shouldComponentUpdate, instead, is useful when a state or prop was changed, but it's possible to quickly detect that the change won't require a DOM update anyway.

Re: Switching From React To Vue.js

#22
post #9

I have (some) experience with both React and Vue 2 and definitely prefer the later. Vue is very minimalistic but unlike React provides a lot of functionality out of the box. Stuff like the router, the computed properties, automatic change detection, HTML templates, scoped css, animations, ... . But what's more important is the fact it does all these things in an extremely elegant and unobtrusive way. The computed pro…

> unlike React provides a lot of functionality out of the box. Stuff like the router, the computed properties, automatic change detection, I never studied Vue, but the article starts saying "Both have separate, but commonly used, router and state management libraries". This doesn't look like "out of the box" to me.

https://vuejs.org/v2/guide/routing.html

For most Single Page Applications, it’s recommended to use the officially-supported vue-router library. For more details, see vue-router’s documentation.

https://github.com/vuejs/vue-router

--

https://vuejs.org/v2/guide/state-management.html

Vue offers vuex: our own Elm-inspired state management library.

https://github.com/vuejs/vuex

--

Out of the box or not, they're part of the same github org, they're officially supported and they're documented in the official docs. I think this is just splitting hairs.

Re: Switching From React To Vue.js

#23
Do people like Vue because it's more declarative than react? Is it mostly angular devs switching and getting the best of react but still having directives?

I like the control react gives me without the black box 'compiler' which seems like it makes a bunch more choices for you.

I'm probably biased, someone cmv?

Re: Switching From React To Vue.js

#24
post #14

Earlier quoted context omitted.

Mobile Twitter uses React. https://mobile.twitter.com/facebook Airbnb uses React https://www.airbnb.com.au/rooms/432044 Facebook, Facebook Messenger, Instagram, Netflix, Reddit Mobile, new Reddit Profile pages are all high profile sites using React that aren't just 'backend dashboards'.

Interesting. The ones not behind a login (Twitter,AirBnB,Reddit Mobile) are sites that feel laggy and clunky to me. With slow loading content, loading animations, laggy scrolling, too much stuff opening in new tabs, confusing interfaces. I wonder if React causes/incentivises this or if it's design decisions by the coders/designers/managers. In contrast, pages like Reddit Desktop, Google and Amazon work much better fo…

> I wonder if React causes/incentivises this or if it's design decisions by the coders/designers/managers.

Both. React makes it easier to write complex JavaScript web apps. Complex JavaScript means you have a lot of rope with which to hang yourself.

Re: Switching From React To Vue.js

#25

Our company migrated to vue.js, 4 months ago. Our complex app is messy with JSX, router, and new dev can't keep up with code. Now we start every new app with Vue.js. The gap between junior dev and senior dev comes closer. They can collaborate with less bugs, less problems and less time to develop.

Is it because of the technology or because of the team? Rhetorical question - I am by no means attacking you or your team, I just clicked on your "is messy with JSX, router" sentence and decided to put my reply under yours.

I see many people tackling React but not developing in a 'React' way. For example I recently saw on HN some user complaining that he had to create N functions to handle N items on a form, while computed properties would have done the trick with only one.

I have no experience with Vue but extensive with React, having developed both small and bigger apps and the only real issue for bigger apps was that it was hard for new users to grok the project initially because of the component-based approach of React.

I do agree that the learning curve for React is pretty steep, but you reap the benefits later on as React 'scales' extremely well in my opinion.

Re: Switching From React To Vue.js

#26

Do people like Vue because it's more declarative than react? Is it mostly angular devs switching and getting the best of react but still having directives? I like the control react gives me without the black box 'compiler' which seems like it makes a bunch more choices for you. I'm probably biased, someone cmv?

I hate directives. There is nothing you can do with them you can't do with just plain callbacks or putting React components inside another that renders its children. HTML templating directives are stupid too, I find myself looking up syntax references for angular even though I've used it for ages. (Think semicolons and magic variables like `$event` or `index` in *ngFor bindings – you don't need these unfortunate and necessary syntactic choices if you just use JSX.)

So yeah, Vue is probably slightly more declarative than react, at the usual cost of having to learn all the declarations. When I first looked at it, I saw the 'v-' prefix on HTML attributes and just stopped.

Re: Switching From React To Vue.js

#27

> ... If message is passed as a prop to any child components, Vue knows that they depend on this will be automatically re-rendered as well. That’s why there’s no need for a shouldComponentUpdate method on Vue components. I think that React does the same? If a component's props and state don't change, shouldComponentUpdate doesn't get called at all IIRC. shouldComponentUpdate, instead, is useful when a state or prop w…

There's a default shouldComponentUpdate implementation in the React.Component. It does a shallow compare of state and props. When you define shouldComponentUpdate you are just overriding that implementation. So it's always called, its just you don't need to always define it.

Re: Switching From React To Vue.js

#28
post #19
post #8

Earlier quoted context omitted.

Reddit's new profile pages and their mobile web app both use react.

These? https://www.reddit.com/user/spez Aren't those just static html pages rendered serverside? Is there a blog post about them or something?

If they made a technical post about them I haven't seen it, but there was an announcement for them as a feature.

I just know that my react-devtools extension and the redux state inspector both lit up when I went on that page.

Re: Switching From React To Vue.js

#29

Earlier quoted context omitted.

> unlike React provides a lot of functionality out of the box. Stuff like the router, the computed properties, automatic change detection, I never studied Vue, but the article starts saying "Both have separate, but commonly used, router and state management libraries". This doesn't look like "out of the box" to me.

https://vuejs.org/v2/guide/routing.html For most Single Page Applications, it’s recommended to use the officially-supported vue-router library. For more details, see vue-router’s documentation. https://github.com/vuejs/vue-router -- https://vuejs.org/v2/guide/state-management.html Vue offers vuex: our own Elm-inspired state management library. https://github.com/vuejs/vuex -- Out of the box or not, they're part of th…

Redux has been from the same github org for a very long time too: https://github.com/reactjs/redux

And react-router, while not being on the same github, is pretty much considered a standard too. It's ok to not split hairs for vue.js, but then you shouldn't do the same for react...

Re: Switching From React To Vue.js

#30
post #2

The major problem with this tutorial is that it doesn't cover single file components ( https://vuejs.org/v2/guide/single-file-components.html ) at all, which are superior to (and preferred to) implementing string based render functions (which rely on a runtime template compiler). Indeed, the Vue NPM package doesn't even provide the runtime template compiler by default. Stuff like what the article promotes are great f…

> The major problem

I did not see it as a problem. I appreciated the light weight approach being shown first. In fact, for my use case, I prefer not to bring in the ecosystem. That could change, and the article introduces the heavier approach.

> the way that you're actually supposed to do things

The one message that comes out of the Vue camp and happy users is that Vue can fit many project types - small to large. Not having to always use single file components is the pragmatic part of that inclusionary message.

Post reply on HN