User avatar
Grifdail @grifdail@social.grifdail.fr
7mo
Learning Vue so I can put it on my resume and obviously my first reaction is "I prefer React"
2
1
0
0
User avatar
Grifdail @grifdail@social.grifdail.fr
7mo
Basically my UI philosophy for the last 10 year has been "UI = app(state)" : What you see on the screen is the result of calling a (pure-ish) function passing it all the data of your app. When the data change, you call the same function with the new data and you get your updated UI.

React is basically built around that metaphor. The components are functions that call other components-function and return what is basically html. Except that not exactly true because it would be very inconvenient. React function components are not Pure function but they rely on side-effect. Components can have their own state, you can add imperative side effect and you don't actually output html but virtual element.
Still, it's all hidden away behind the metaphor of function. And I like it because it match my mental model of how UI works.

Now from what I understand, vue logic is exactly the same as React, you still compose components as if they were function. You still have data that flow down the call tree. Components can also have their own state and side effect.
The only difference is that Vue doesn't use the function metaphor. Vue tell you more explicitely that you're manipulating an object whereas react hide it away.
That's a tiny subtle difference and it's all in my head but it's there. I'm probably gonna get used to it.
1
0
0
0
User avatar
Grifdail @grifdail@social.grifdail.fr
7mo
A tiny example is the way you do loop.
In react you explicitely return what you want so if you want a list you return
{{list.map(item => <MyComponent />)}}
In Vue instead you tell the framework via the v-for directives "Copy this template for each element of this list".
Again, deep down it's absolutely the same, but in my head there's a tiny difference in the way I think about my code and I don't like it.
1
0
0
0
User avatar
🪨 @Varpie@peculiar.florist
7mo
@grifdail En un sens, React te demande d'apprendre JSX qui mixe du HTML dans le JS, Vue est plus proche des technologies natives avec des templates HTML qui sont envisageables avec des WebComponents (mais qui peut directement passer des objets réactifs en paramètres, et avec certaines directives utiles genre v-for et v-if) + du js pour la logique.
⭐1
1
0
0
1

User avatar
Grifdail @grifdail@social.grifdail.fr
7mo
@Varpie oui c'est ca. React fait son maximum pour cacher le fait que c'est plus compliqué en arrière plan. Ils te font "croire" que tu manipule directement de l'HTML a travers le jsx. Y a beaucoup de "magie"
Vue ne prétends pas faire ça. C'est beaucoup plus proche de l'implémentation réel. C'est des template. Les ref sont mutable (si j'ai bien compris). ...

Ça cache pas que c'est construit sur les technologies du web en gros. J'ai envie de dire c'est plus "réaliste".
0
0
0
0