3 ms·
In Vue it would be: <p v-for="(vars, i) in collection" :key="i"> {{ vars }} </p> Instead of: { collection.map((vars, i) => <p key={i}> {var
by BiteCode_dev 7y ago
In Vue it would be:
<p v-for="(vars, i) in collection" :key="i">
{{ vars }}
</p>
Instead of:
{ collection.map((vars, i) => <p key={i}> {vars} </p> }
It's easier for me to picture what the first example is going to render because it makes the markup the hero, with code inside, while the second example is making JS the hero, with markup inside.
But this example is not even touching the topic. A render function is rarely that simple. Now if you do maps, and filters, and ternary operators, and && / || pass trougth, and set several class conditionally, and pass an event and do preventDefault, etc., now you have a more real life example. And in react you'll get __a lot__ of JS, with very little markup. And you'll have either a lot of boilerplate, or a lot of dependencies to get helpers.
While in Vue you'll get mostly markup, with a little code inside. It will read from top to bottom as well. No needs to wrap stuff in arrow functions to get the event object. PreventDefault has a helper. Setting classes as well. I prefer that.
- Rapzid 7y agoVue's templates are great until they aren't, and then you wish you were using JSX. The IDE tooling is worlds better with JSX as well. Vetur has.. had a rough year.
- BiteCode_dev 7y agoI don't have to debug my render functions much in vue because they contains little logic. Debugging is more common in JSX, it's better at solving a problem it introduces.
- robertoandred 7y agoThe second example isn’t making JS the hero, it’s making data the hero.
- BiteCode_dev 7y agoWhich is the opposite of what you want in rendering. Ui is king here. Data has the rest of the code to shine.