Earlier quoted context omitted.
Another chart worth viewing: https://www.hntrends.com/2017/july.html?compare1=React&compa... Hiring is a lagging indicator, but I see React hitting a plateau the way angular did. I see Vue is on the cusp of takeoff. Time will tell if it fails to launch, but I'm seeing more interest in Vue at meetups than React. I think a lot of this has more to do with React's state management than licensing. One of the react develop…
Redux is completely optional, 3rd party library. So I really don't understand why anyone would say that. You don't like Redux? Don't use it.
Vue.js vs. React
371–380 of 486 posts
Re: Vue.js vs. React
#372In this thread people are fighting about their _opinions_ why they use Vue.js or React. And why X is really better than Y. In reality these programmers don't want to have the feeling they might have made the wrong choice when they used X instead of Y. The idea that they might have taken the poorer choice hurts so much that they need to defend their decision so heavily while in reality taking ReactJS or Vue.js is like…
The reality is it is all shite! Just get your job done.
Re: Vue.js vs. React
#373For example, for one of my libraries I wanted a really simple way to allow people to include custom templates. I started with string-based templates, but quickly realized that this was inflexible for any kind of event binding or later dom mutations. Achieving that was super easy with jsx -- I just implemented a custom jsx function which directly outputs DOM elements.
Step 1: implement a jsxDom function [^1] which takes (name, props, children) (e.g. https://github.com/krakenjs/xcomponent/blob/master/.babelrc#...)
Step 2: point babel to my jsxDom function (e.g. https://github.com/krakenjs/xcomponent/blob/master/src/lib/d...)
This even allowed some cool hacks like including iframes directly in the jsx, to sandbox sections of the page (since the library is geared towards creating components to be embedded on 3rd party sites):
containerTemplate({ jsxDom }) {
return (
p {
margin-top: 40px;
}
I can be sure the styles in this iframe won't affect the parent page
)
}Re: Vue.js vs. React
#374Earlier quoted context omitted.
React does not force JSX use. JSX just compiles down to React.createElement.
I feel React.createElement is so unergonomic it's not really an option to use directly. A lot of React supporters mention it when people criticise JSX, but I don't think it's a pragmatic alternative.
Re: Vue.js vs. React
#375Earlier quoted context omitted.
I wonder if the JS snippets in those attributes is syntax checked at build time or run time.
Vue templates are compiled into render functions. They are checked when the template is compiled. If you are using a build process, then that would be at build time.
Re: Vue.js vs. React
#376Earlier quoted context omitted.
I'm not sure I follow. To use the basic example from the link, as opposed to this: const listItems = numbers.map((number) => {number} ); return ( {listItems} ); What's wrong with looping this way?: return ( {numbers.map((num, i) => {num} )} )
> What's wrong with looping this way? The problem IMO is that it's harder to read and write than: {{num}} That's Vue's syntax, but any other templating language is more readable to me than JSX.
I don't understand how
{{num}}
is less readable than
{listItems.map((num, i) => {num})}
Both are pretty readable, but the latter is essentially normal javascript, with the idea that you can return dom elements in it. The only thing that a javascript developer with zero jsx experience needs to know is that you can express dom elements within your javascript and treat them exactly like functions that return that element (which is what they are).What someone has to know to parse your vue example is the exact syntax for for loops in vue, evidently the syntax in this example is quite simple but what if they want to perform extra logic in that loop to modify which elements to show? In the react example all they have to do is know javascript.... in Vue they have to go look up how to do that in Vue.
Re: Vue.js vs. React
#377Earlier quoted context omitted.
I find the JSX loop infinitely easier to understand what's going on. It's a javascript map. With your Vue example, what is listItem? An array? Can it be an object? Does listItem need a special decorator for v-for to be able to loop through it? So many initial questions that just aren't there if you just use Javascript.
it's just plain for(x in list){ .. } v-for="item in list" if you need idx: v-for="(item, i) in list" pretty standard stuffs
Re: Vue.js vs. React
#378Actually my major complaint of React is the state of state. There seems to be no common knowledge about how to do this right. I just joined a team that has two React projects that development started about two months ago (I just joined like a week ago). There is a a large component that I am working on that is completely bound to Redux. There are major state update issues and the team had opted to assign IDs and data…
This sounds awful and seems like an anti-pattern. I don't think this anything to do with React (other than perhapps that React gives you the freedom to do things wrong). Your devs don't have a proper understanding how React (or Vue) works. Define state model, define view, modify/interact with state, let React modify view. That way you'll never need dirty hacks like fetching state from Redux by using the DOM ID.
Re: Vue.js vs. React
#379Earlier quoted context omitted.
Vue templates are compiled into render functions. They are checked when the template is compiled. If you are using a build process, then that would be at build time.
Is there any editor support for that? One of the things I like about React + TypeScript is that the JSX is syntax-checked and type-checked in my editor as I type. My understanding is that this is possible because TS has built-in support for JSX.
Re: Vue.js vs. React
#380My #1: download vue(.min).js and you are ready to go. No packagemanager, bundler and what not needed.