Seems like they should try more marketing and community outreach toward that end.
Gradual adoption is a feature / selling point not many web development frameworks can claim.
For instance, I work on an app that was originally written in Backbone / Marionette, but I was able to write generic connectors to allow us to drop in React at any point in the tree. Similarly, we can go back to Marionette / Backbone at any point in the tree. It's made gradually migration towards React possible.
Claiming React can't do the same sort of sprucing up as Vue is just a lack of imagination. Show me an old app, and I'll show you how to do it.
I think this exact capability is what led to such strong React adoption. It's almost viral within an application. The main application that I worked on a few years ago was on Backbone / Marionette and we evaluated React by writing several small but complicated nested components, with state controlled by existing mechanisms. After liking both the flux application architecture and the ease of gradual transition, we pulled the trigger on React. It slowly ate our application from the inside out, but never forced our hand.
React isn't "lightweight" (JSX being the primary hurdle), but it is very easy to adopt incrementally!
I find it the other way. Vue has a big learning curve. Learning their special directives and double binding gotchas takes a while.
While jsx is a very thin layer for existing Js. All control flow is good ol js. The tags just translate to createElement/h calls. React (class based React) was easy to pick up.
Vue has similar hydration capabilities as Angular, but with React, you are pretty much forced to describe the view from scratch in JSX. To make things more fun, many islands need to be aware of each other, something that is not super idiomatic in React land.
Just some food for thought.
I think it's all pretty much the same deal. You might argue Vue's template syntax is closer to HTML than JSX is, but that doesn't really feel like the major issue when slowly refactoring a large application.
That's just not true, I've just finished working on a client project creating a migration scaffold between react and angular-js - like someone mentioned above, there are libraries to support communication and embedding both ways.
People will respond saying you "can do this with React, too". But in practice it's not nearly as nice to do as with Vue. You need React and React DOM AND JSX to really make it practical; writing React render functions is not really what you want to do when you are adding some simple functionality to an existing web app (like form validation).
If all you are doing is adding a simple form validation to an existing web app, then you only need few lines of plain JS. You don't have to use vue either.
Meanwhile the web development team are still fighting with the flagship "all-or-nothing" angular app, still stuck on 1.7 because anything else is an entire rewrite.
what you're responding to is marketing, which Vue has done an effective job of. thats fine, but it is unfair of you to conclude "Gradual adoption is a feature / selling point not many web development frameworks can claim."
While it isn't pretty, you can drop Vue in a <script> tag on a page and define components with template strings.
In React, you can technically do this, but you need to either:
A. Use React.createElement() calls
B. Use something like "htm" also included via a <script> tag, with template literal tags to wrap your component renders
You can technically include Babel in a <script> tag to use JSX, but it only works with <script> blocks that have been tagged as "JSX", not within regular ".js" files you can import using "src="
Jason Miller a-la Preact is the person I see most consistently working on and pushing this sort of React/Preact no-build setup. I definitely get the appeal, for this exact usecase -- you have a simple, mostly-static website (or something old and built with jQuery) and you want to incrementally modernize it/add functionality without rewriting the whole thing.
You can go pretty far using Vue with a <script> tag before you start needing build tooling.
I don't know if you intended it this way, but the start of this comment makes it automatically flamebait.
Discussion around release announcements can quickly turn into a flame war. Please use caution.
This has allowed me to do things like create Vue-based tools in a locked-down corporate environment where I was not able to install Nodejs on my machine.
My first year of React development was without JSX even though we DID have a build step (I was categorically against it at the time. Things changed, haha).
For instance, Vue provides a method to explicitly declare your template variable delimiter syntax. Last time I looked this was requested of React, but not implemented, someone correct me if I'm wrong on that and it has come along in the last year or two. So.. lets say you wanna put some modern Javascript in some Django templates to make them look spiffy. With Vue you can just declare your delimiter to be `[[` instead of `{{`, (because `{{` conflicts with Django's template variable syntax) with a one-liner setting.
I'm sure you could do this in React with a custom parser function (or maybe there's a third party library?) but it's a lot easier when the framework just gives such things to you out of the box.
If I do this all over the place and some other guy comes along years from now with no documentation on what he's getting into, he doesn't need to know too much to figure out what's going on and work on it. Right away he'll see "delimiter = [[" at the top of the script block in a template and can grep double brackets in the whole project to get an overview of what's being done.
99% of the time, HTML is easier and faster to write, with the built-in directives providing all the functionality you need. More importantly though, HTML can be generated by every single server-side framework, and this makes it very easy to have server-side code from any language stack that becomes interactive using a Vue client-side layer.
So if you want to use it on one page, it's a hard sell to set up all that infrastructure (and document it for the team)
On some sites I've used Vue.js by simply adding a <script> tag with vue.min.js.
On sites already using Gulp or similar, it's pretty simple to incorporate the Vue bundle and use it on one or a few pages.
https://reactjs.org/docs/add-react-to-a-website.html
Having said that, React is normally used with JSX syntax, which requires a compile step.
You _can_ use it with "raw" `React.createElement()` calls, but that's generally unwieldy and almost no one does that.
However, there's a very neat library called https://github.com/developit/htm , which is an almost-JSX-compatible syntax that uses JS template literal strings, and requires no compile step.
https://github.com/arijs/vue-next-example
I already integrated vue-router, and am currently on the process of fully integrating Vue server renderer. I already have a basic usage implemented, where the home page is compiled to a html string, but I still need to make it easy to compile all pages and to implement client-side component hydration.
https://shinglyu.com/web/2018/02/08/minimal-react-js-without...
All this FUD spread by the Vue fans is getting ridiculous...
I'm seeing a bunch of commenters getting defensive and saying "well technically" while conveniently ignoring the difference in effort required to do islands in each framework. You can't say dropping JSX is at all comparable to plopping in v-clicks on existing HTML.
You can certainly adopt react "incrementally", in the sense that you can implement an entire new self-contained feature and plop it into an existing app if it already uses REST APIs, but react is decidedly not as trivial to sprinkle into a non-SPA where data comes mixed with HTML rendered on the server.
Saying React can't do it, to paraphrase you, because "technically it's harder than with Vue" is like saying nobody can drive a stick shift because you have to shift gears manually.
Yes, you have to do it manually, no it doesn't make the car undrivable.
That's what I call FUD.
VueJS has first class support for this use-case while React has "well technically no ones stopping you from figuring it out by yourself" support.
After the package update and some very basic find/replace across our codebase, about half of our 600+ tests had to be significantly updated. If your tests regularly mock a Vuex store or a router, be prepared to be making a lot of updates.
If you're using some of the features being removed (filters, $on/$off/$once, etc) or make heavy use of custom plugins, it's not going to be painless.
Having said that, I love the direction the new API is heading and 95% of the changes we have to make are for the better in the end, so it feels worth it.
[1]: https://v3.vuejs.org/guide/migration/introduction.html#break...
On top of that, v2.7 slated for 2021Q1 also includes the relevant migration warnings, which should help make life easier
Our example (look at diffs): https://github.com/Quantum-Game/quantum-game-2/pull/227
This also gives a chance for a refresh of the ecosystem: libraries that are no longer relevant (eg, their functionality has been incorporated or otherwise made obsolete) can go away, and they get a nice "out" so no one has to feel bad about shuttering a project.
It also gives a chance for keeping the libraries using newer APIs, or even newer libraries to gain traction.
Very similar to doing a controlled burn in a forest: Worse than no fire at all, but orders of magnitude better than an actual wildfire.
I am curious if he ever experience boredom working on Vue.
I am also curious if Patreon based income is sustainable for the long run. What if there's another new sexy JS framework in the future?
That's how a market works. It's a strong incentive to keep Vue sexy.
React and Angular are here to stay, and there's no changing that.
Whether react/angular/vue are able to continue improving enough to justify staying within that world remains to be seen. It's very early days for some of the new frameworks out there, but with web assembly on the horizon, companies will again be motivated to modernize, however that looks.
I've been paid to write Vue code for at least 4 years.
I'd be unlikely to start any new project on Angular. React remains dominant and would be a viable option, except Vue feels more lightweight and approachable. I'm sticking with Vue for now.
This company focuses on development of Coldbox, a ColdFusion-based framework still in active development. If they can support a team and still continue development, Vue should be good for a while
The Ortus folks are very smart and clever.
Cannot recommend them enough.
I am sure he can save a lot, with that income.
I am sure he could find a normal job, with those skills.
I am sure he could be a freelancer, with "created vue.js" as reference.
His Patreon based income would slowly die with the decline of Vue.js and he'd have enough time to look for something else.
I was curious about this too when Vue 3 overshot its release estimate and then he started working on Vite, which is a build tool.
I think this decentralized web of incentives is more sustainable in the long run than a single corporate sponsor.
What does 120% less memory usage mean, really?
The math is like, if it did use 100mb, and now it uses 25mb, that's 300% less, because 25mb is the "100%", and you reduced by that amount 3 times. Odd.
- "120% less memory usage" - From 9.9 Mb to 4.5 Mb
- "Up to 133% faster updates" - 13.18 (ms?) to 5.64
In both cases, the formula to calculate the percentage is:
= ( PREVIOUS - CURRENT ) / CURRENT
Oh, actually they just changed it. For the memory usage, it's now: = ( PREVIOUS - CURRENT ) / PREVIOUS
..which shows a more intuitive result: -54.55%.I’d just say 75% drop for 100mb to 25mb.
25 to 100 would be a 300% increase.
100 to 25 would be a 75% reduction.
100/25-1 = +3 = 300% increase
25/100-1 = -0.92 = 92% decrease
100/25-1 = 3 (300% increase)
25/100-1 = -0.75 (75% decrease).
100% more of something = 2x more
120% more of something = 2.2x more
120% less of something (problem here!) = 2.2x less = 1 / 2.2 of something = 45% of something
I think the writer meant 2.2x improvement in memory usage rather than 120% less memory usage -- the word "less" used in conjunction with a percentage is confusing.
So 120% less of 10 rocks is -2 rocks, which obviously doesn’t make sense. Which is good, it shouldn’t make sense to have more than 100% less of something.
On a related note, I tend to avoid expressing changes as percentages entirely, in large part because increasing by X% and then decreasing by that same X% doesn't get you back to where you started.
Perf is on par with Preact.
RC4 is not the final release though, we'll see how it goes with 3.0.0
[1] https://krausest.github.io/js-framework-benchmark/current.ht...
For anyone curious, here's the full list:
From a reactivity standpoint, Vue has a much more ergonomic/easy to use API for handling component state, effects, and computed values (in my opinion) than React.
But in the last 6-8 months, I've leaned away from Single-File Components because when you want to do something like define a bunch of small components, it's a lot more difficult to do than with multiple TSX functions you can chuck in one file.
So I've been using Vue with TSX, and the experience (in the last few months only, before that was pretty bad) is okay, but not as solid as you'd get with React.
I'm not the only one who must feel this way, because this exists and has a lot of stars:
"Reactivue: Use Vue Composition API in React components"
https://github.com/antfu/reactivue
Unfortunately, this is a weird stance to take in the Vue community, almost nobody uses JSX/TSX. Because of this, the development efforts towards it aren't as much a priority.
Overall, I'd rate the experience as "decent" and "totally usable", but I hope to see the DX for Vue's TSX community improve over the coming months.
---
Edit 2: Disregard the below, this already exists apparently
Edit 1: Having to write two type definitions for Component Props: one TS interface/type, and one as the JS object sucks. That's my one big complaint.
I know it's impossible because props need a runtime value but someone should make a plugin/babel transform to decorate the "props" key from the generic argument here:
const MyComponent = defineComponent<MyComponentProps>
Use reflection on "MyComponentProps" to set "props" key.There's another comment below discussing this drawback too.
Uh, you don't have to? TS inference works with the JS objects. There's no need to provide the generic argument here.
Also check out this: https://github.com/vuejs/rfcs/blob/sfc-improvements/active-r... (auto-generating runtime types from TS interface)
Happy Vue user since 2016.
> TS inference works with the JS objects. There's no need to provide the generic argument here.
That's totally valid -- I am just being nitpicky and complaining because if possible I'd prefer to do it the other way: TS type -> JS object
> auto-generating runtime types from TS interface
Whoa. Well, that solves that then.
Is it correct that `declare const props` will not only get used to type-check stuff but also emit code based on that?
I think thats unintuitive. TS basically means "take away all the static types and you get what the compiler emits". A lot of developers won't be able to distinguish between TS and the magic that some framework does. I've made similar observations when working with Angular devs.
Correct my if I've mistaken something. /2c
Typed components is 200% of why I'm writing React these days. Angular has typed components too (they went in on TypeScript early), but the Angular Language Service / IDE integration didn't come to later-- so for a period, no intellisense.
But having intellisense while writing TSX is so wonderful, especially when you're working with complex or deeply nested object structures.
I have to hop back and forth between Vue and React frequently and the experience of writing a TSX component is pretty nearly identical.
For stateless components -- it's literally the same syntax as React.
For stateful components, you just need to wrap your component in "defineComponent()" and your TSX elements get returned from a closure in "setup()".
See:
https://cdn.discordapp.com/attachments/568037134968160256/73...
Comment I made about this I dug up:
"The issue seems to be that the definition for RenderContext<Props> puts the props under the key "props", so when trying to define them on your JSX/TSX element, it expects you to put them under <MyComponent props={ } />. If you do this though, it breaks in another way because it's missing the other properties of RenderContext and it's not a great API =/"
This is fixed now though I am pretty sure.
- Lightning-fast cold server start - Instant hot module replacement (HMR) - True on-demand compilation
This part should be of particular interest to you:
https://github.com/vitejs/vite#how-is-this-different-from-vu...
const Component = defineComponent({
props: {
name: String,
success: { type: String },
callback: {
type: Function as PropType<() => void>
},
message: {
type: Object as PropType<ComplexMessage>,
required: true,
validator(message: ComplexMessage) {
return !!message.title
}
}
}
})
Contrast this with React where this would be something like this (I think; I've never used React): interface Props {
name: string;
success: string;
callback: () => void;
message: ComplexMessage;
}
export default class Component extends React.Component<Props> {
...
Quite disappointing. Maybe not that surprising given Evan said he only started using Typescript very recently, and many beginner Javascript developers don't realise that they should really be using Typescript (fortunately Evan isn't one of them). I would recommend still avoiding Vue for this reason alone.Instead, there's the compiler-based approach with `<script setup lang="ts">`: https://docs.google.com/presentation/d/1VjBM6ae-fuawK1TltYLX... (runtime props definitions auto-generated from TS interface)
Fair enough on not wanting to break things, but I still feel like it is Vue's second biggest flaw and worth breaking to fix.
https://class-component.vuejs.org/
You get to define your components as classes with their methods and properties, and can declare props and watchers via decorators. Overall a good typescript experience.
It's interesting to me that they did not consider the approach of pushing more work to the compiler and less to the runtime in the manner popularized by Svelte. I wonder what the trade-off between their current rendering approach and the Svelte-based approach are?
they certainly did, lol. the tradeoff is the same it's been; they want all of vue available in a script tag.
It is interesting though looking across benchmarks though and seeing non virtual DOM frameworks crushing their counterparts in terms of speed. I wonder if we'll see more growth in that space in the future.
You may be aware but it's also important to note that everyone is trying to cheat these benchmarks so they don't mean much. The implementations aren't data driven and don't look much like how we'd write real world code. See the discussions here including the linked issues and PRs https://github.com/krausest/js-framework-benchmark/issues/77...
A while ago I wrote the same component in Vue 2 and Vue 3 as an example of one versus the other:
https://codesandbox.io/s/bold-shamir-uqm0b?file=/src/compone...
https://codesandbox.io/s/bold-shamir-uqm0b?file=/src/compone...
If you meant more from a conceptual standpoint -- the usage patterns with Vue 3 is pretty nearly identical for most people. You just replace "data()" property with some "reactive()" state value in setup (or "ref()" for single values).
You CAN write things like generic hooks/"useXXX()" helpers, but you likely won't wind up with a ton of those.
Also, about the reference passing: it doesn't actually really work like that. If you pass a "ref()" or "reactive()" value as a prop to a child component, and you mutate it there, it doesn't propagate to the parent.
Vue will throw this warning:
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "someRef"It (passing mutable values around) does make it harder to understand the data-flow, yes.
But we programmers keep assuming our rules & protection & orderliness are helpful & necessary. And those patterns we opt in to keep getting codified, embraced. But along comes someone who breaks those rules, & it keeps turning out, a lot of the things we think we do to be orderly & safe & sensible are actually not that helpful at all, or have impeded really wonderful progress elsewhere.
I think of React. Until React came along, everyone doing web development knew, it was obviously correct, that we needed templating languages. We knew we needed content & code separate. We knew content was obviously a different beast than code & that content should have tools designed for content. As it turns out, mixing code & content actually works really well & that we had ruled out a wide space of possibilities that were really simple, powerful, & direct.
Relatedly, here, with shared-mutable-variables, I'd pitch that hopefully tools compensate for a lot. Hopefully it's possible to run the app & see who is modifying values, see who is being updated when values change. It's nice being able to have the code tell you, up front, easily, but also hopefully watching at runtime is possible, makes it easy to suss out what the connections & causalities are within a system.
That said, if you want to use the composition api to share state you can, and you can pretty easily set up some structure to restrict mutability:
// useStore.ts
import { reactive, readonly } from 'vue'
export const useStore = () => {
const state = reactive({ count: 0 })
const increment = (val = 1) => state.count += val
return {
state: readonly(state), // Readonly so state can't be mutated directly...
increment, // ...only through the mutations provided, like Vuex
}
}
// store.ts
import { useStore } from './useStore'
export const store = useStore() // Now components can share this instance
// MyCounter.vue
import { store } from './store'
export default {
setup: () => ({
count: store.state.count,
onClick: () => store.increment(5),
}),
}
Or you can just keep using Vuex for sharing state and use the composition API for sharing self-contained bits of functionality. Or, if nothing else, using the `setup` method instead of the Options API just gives you much more control over how you organize your own code within a component.Vue (and some other frameworks) use a reactivity approach where the data is wrapped with a proxy that basically automates all this code. I find it much easier to reason about since it greatly reduces the complexity and you can focus on the actual data changes rather than all the plumbing to change the data.
Could you expand on this a little more? What is it specifically that makes it incredible compared to React, in your opinion?
Also, I really like the data binding which vue took from angular. That was always by far my favorite part of angular, rather than having the binding be written in JS which feels too mechanic to me. I dont feel like I'm writing HTML / front end code, I feel like I'm writing a hybrid mecha mutant of JS + HTML + weird syntax.
I can hand a project to a junior dev and not have to explain project structure or patterns, nor worry about things going off the rails. Generally, after getting a feature working, most of the feedback I'll need to give is "break this 300 line file up into 3-4 smaller ones". Great ESLint rules provided by the Vue team really help with this.
With Vue 3, with the two APIs, I know that I'll be able to hand a feature off to a developer of any level and know they can accomplish it however it makes the most sense.
I can also jump into a legacy Vue app built by another team and have no issues getting oriented. In my experience with React, I haven't seen the same router configuration twice. Most React projects I've inherited feel over engineered
On a more meta level, I think the single-file API its a much better mental model than React's. Your HTML is still just HTML, and your styles are CSS or Sass, or whatever you choose.It's why I preferred AngularJS over the others at the time.
(just a Chrome extension) https://github.com/FastComments/fastcomments-debug/blob/mast...
I agree that templating of data is something you should use a library for. But there are great templating libraries. Handlebars for example.
Can someone give a short example of code that would be more elegant using Vue then just a simple template engine?
You could also create your own components with HBS templates and figure out how compose them to render a tree of components. That's not too hard to figure out either.
The problem is really in updating the DOM when state changes somewhere in your application. In the jQuery days we had tons of micro DOM managing code so that when some variable changed then we would update some piece of the DOM by "hand". But as your project grows this becomes a mess pretty quickly.
Another solution could be to simply re-render everything and update all the DOM on every frame with a state change. That would simplify your code but it would probably be extremely inefficient.
The point of libraries like Vue, React, Svelte, etc, is about simplifying the production of sophisticated UIs, as efficiently as possible, so you can focus on the right abstraction instead of the implementation details (eg: managing the DOM).
Every library takes a very different approach. If you're coming from the vanilla/jQuery world the learning curve can be pretty steep. But, as someone who has been doing web frontend for 20 years, I think the price of admission is worth it.
IMO Vue is probably the easiest one to get into. You can get started by simply including it in a script tag as if you were using jQuery.
Say a function changes the cars array. All it has to do to update the DOM is:
document.querySelector('#cars').innerHTML=carsTemplate(cars);
Where carsTemplate is a HandleBars template that on page load has been initialized with the html to render the list of cars.
In my experience, the approach you're describing doesn't really scale and only works for the most simplistic use cases. In a real world scenario you would have dozens if not hundreds or thousands of arrays/vars that are related to the view.
Even only considering we're talking about rendering blocks of dynamic HTML: How are you going to keep track which state changes affect which parts of the DOM? Are you going to have hundreds/thousands of innerHTML code all over the place? What is going to happen when (not if) you change your template?
Then you need to start considering, event handlers, initialization code for every car view, etc. Imagine those event handlers modify the state of a single car in your array. Are you going to repaint and re-initialize the events of all your cars on every mouse event? Again, that would probably work on very simplistic use cases.
I'm not describing anything new. These problems are what motivated people to create Ember, Backbone, Angular 1 and other frameworks some 10 years ago. But the JS world has moved on from that paradigm into the reactivity+components thing which is a much better abstraction in terms of developer experience, performance, memory consumption, etc [1].
[1] https://medium.com/dailyjs/a-realworld-comparison-of-front-e...
function update() {
let value = document.querySelector("input")?.valueAsNumber;
document.querySelector("main").innerHTML = `
Enter a price: <input type="number" oninput="update()">
<br>
Discounted price is ${value * 0.8}
`;
}
update();
What will happen is each time you enter a character, it will create a new input element, which loses the focus and cursor position.To solve this we can split it up so that the inputs are created once and the output is updated with innerHTML. No problem, right? But it's hard to scale up because now you have to split the html up into small segments based on whether there's internal state or not. If you want to update the 'max' of an input type=range, you aren't doing it with handlebars anymore but you have to use setAttribute instead.
What react, vue, etc. do for you is handle the updates in a way that reuses the existing elements. If you changed any attributes of the <input type=number>, it will not lose the focus and cursor and any other state. If you change the max of an <input type=range>, it will update the existing element (using setAttribute) without losing any other state. If you change some text, it will update the existing text node using innerText/textContent.
You may not need this type of system. I think React, Vue, etc. are overused. But in some projects it's much cleaner to use a React/Vue/etc. style system rather than splitting it up where some segments use setAttribute, some use innerHtml, etc.
What the above code will do is completely replace the HTML for the entire list of cars, when really all that needs to happen is appending one to the end. If the list is big, your app is now slow.
If the user has something focused or edited in that list of cars (let's say they're editing the description of one), not only is focus lost on that field now (its DOM node was completely wiped out and replaced), but the user's text they were editing is also lost.
Now you have to update the DOM 3x and remember that the filter you set in that one place over there means you need to only show BLUE cars in this one place over here.
When you start to build things where one piece of data is not just shown in multiple places, but is dependent on other pieces of data, managing your state starts to become more difficult than the methodology you're describing.
There are benefits to using the industry standard (which today I consider Vue, React, Angular and slowly Svelte), you can learn it quickly, as it has ton of resources and you can hire easily, as you aren't forcing someone to use some obscure, home baked js framework.
That's my take at least.
Then you are in trouble regardless of what you use :-)
A dashboard is usually for me the primary use case for one of these reactive frameworks.
I still don't get why it's okay for every other programming language to use the STL or huge dependencies, but doing so with javascript is frowned upon for some people. You wouldn't write a JSON parser yourself in CPP, you'd install something from conan or use the STL or boost for that. Why is it so bad to do the same with js?
If you're building complex user interfaces or a large-scale web app, then hell yeah, you want to use React or Vue.
For reference: I recently built a really large scale website with react, including a content-management-system, custom fonts, around 50 pictures and a ton of tracking. It weighs 1,1MB total. The first request without lazy-loaded resources only uses around 200KB. Can't really argue against that.
This link might contribute to your evaluation. It's a seemingly reasonable overview of the top three frameworks. Author recommends using all three, spoiler?
- 10+ breakdowns for report - 10+ filters for report - Each filter has an include/exclude dropdown list which then has multiple features within even a single filter (so some filters are EQUALS/NOT EQUALS) others are INCLUDES/DOESNT INCLUDE/EMPTY/NOT EMPTY and all the appropriate options for each filter, not to mention clearing filters, etc - column sorting - column hiding - filtering with search - pagination on both client and server side (50K rows batching into sub pagination groups which client side takes over on server batches) - a dropdown at the top which re-initializes EVERY piece of data with a different account and changes quite literally re-initializes 50+ "states" of the UI on the page
Thinks of google analytics
First of all, we can assume doing this on the front end is 100% required. Imagine using google analytics where every single option you change is a backend request. Impossible, so now that weve gotten past that...
Imagine using something like jquery or custom JS where you try to manage the incredibly complicated input/output nature of each component of the page.
Component based design is required because you can keep all your logic for the entire app for a single TINY piece of the app in its own file. So something like a dropdown menu can get its own component called `<DropdownMenu>`, and within that you define all "outer state" that component can use as a prop, or input state (so for example, you want the items that appear in the list to be defined OUTSIDE the component so the component can be re-used). However, that component also has its own internal state, such as whether its open or not, whether its animating or not, what item is selected etc, so if a component has internal state, then you store it IN the component itself. So now the 'state' of EVERY component on the page is defined in 2 places... the originator of the state (such as the component which holds your API calls), or in the component itself. When any change takes place in ANY of those states, all components related to that state "update" automatically to use that new state. This means by simply making a new API call, the outer component state changes, and every single component that relies on that state updates accordingly, even for the most complex UI imaginable its trivial to think about 95% of the logic because all the state is exactly where you expect it to be, and when there are infinite numbers of nuanced side effects, you usually program them IN the component and you dont have to clutter your actual logic (say for instance the api updates your base state, you want the dropdown to reset to zero, so you would code this into the component itself, so that everywhere on the page that uses this component it would all follow suit).
You can have a "DropdownMenu" template, feed it the data (which you call "state") and update the according element on screen just fine.
Invested a few weeks on Vue a few months back, then the concern about 'React has 80% market share and you can find React developer much more easily in the west" never went away.
Maybe Mithril is the way out? I just need a really light-weight client-side-ajax MVC for some embedded product webUI, in fact jquery+BT might do the job well but again, jQuery is not modern any more.
Not a frontend guy, picking a direction there has always been challenging.
if I pick less known but easier-to-learn-got-job-done option I expect to invest less efforts, thus market-share is less critical for the concerns.
Vue 2 was kind of possible to get up and running with a script-tag to get components in a pre-existing app.
It works well with the Composition API plugin for Vue 2 though. They have a dedicated package for this.
With the Nuxt VCA + Nuxt TS plugin, the experience is solid IMO.
Doesn’t webpack support actual tree-shaking (not just modules) or is that still a Rollup-only feature? There should be little difference in size in importing packages vs files if tree-shaking is on.
$childRef.setData({ data })
When i see this code in a Vue codebase, my mind got hurt.
I still prefer React due to its consistent reasoning about data flow in the app.
First, `$childRef.setData()` appears to be the conceptual equivalent in React of `childClassComponentInstance.setState({someField})`. While that's technically possible, it's _extremely_ non-idiomatic in React and completely discouraged.
Second, "forwarding refs" is a feature specifically designed to allow a component to apply a ref to something _inside_ of itself. For example, the React-Redux `connect` API uses ref forwarding to allow `<ConnectedComponent ref={instanceRef}>` to hand back the inner wrapped component, not the outer wrapper component from the library. It doesn't have anything to do with calling a state setting function on a component in and of itself.
I wish I could ignore IE11, but the reality is that I can't.
They need to add the vue2 logic for reactivity. And use polyfill for any other advance features
> updates (up to 133% faster)
How can something be > 100% faster?
Then 133% faster means 2.33x faster (takes 1 / 2.33 = 0.42 the orig time).
should i learn vue3 or svelte instead?
These days I'm focused on Svelte. It's faster and lighter, but IMO the best feature is you write a fraction of the code. When I go back to old React or Vue projects I want to cry. Svelte is so much more zen.
OTOH the ecosystem is minuscule so you are on your own. The support for TS and testing is not great either. Svelte is easy to learn but it's not very popular yet. I would understand if someone argued it's a risky bet although I'm building my SaaS with it.
About a year ago I had to tackle a few new web projects so I decided to give React/Angular/etc another look... and promptly went hunting for alternatives again, and that's how I found svelte. We've got 5-6 svelte-based projects in production now and have really, really enjoyed it.
All that said, I haven't looked at vue3 in depth yet, so maybe it's amazing, I dunno. :)
Also, give it a few more months before building anything non-trivial. Some of the more popular libraries for Vue 2 still need to up updated for Vue 3 (vue-router, vuex, for instance).
It's incredibly easy to use and I've (personally) liked it a lot more than Vue(2).
I researched tech required in job offers and React was first, running circles around Angular and Vue. Nobody spoke of Svelte
ref() is for single values, and to get at the actual VALUE, you need to use "myRef.value"
const state = reactive({ msg: "hello", count: 1 })
state.msg // "hello"
const msg = ref("hello")
msg.value // "hello"
Though when you use ref()'s in templates, it will bind to .value for you.Do experienced Vue devs actually use both regularly?
You can also just call "toRefs()" on a "reactive()" object though.
Refs are also useful if you want to destructure a reactive object without breaking the reactivity, scroll down just below this:
I don’t always reach for Vuex, but when an app reaches a certain size it sure beats passing every bit of common data down through the entire tree, as I find you quickly hit a point where you’re passing data to components solely so it can pass it to it’s children.
(I get that there are some nice features like time travel debugging etc but none of them seem outweigh the giant additional complexity of routing every single state change through 1-2 extra layers.)
Benefits: easy to create, type safety is simple.
Drawbacks: you don't get a serializable state log for free (that can be recorded and replayed when hitting bugs).