4 ms·
> <component :is="condition ? 'WrappedComponent' : 'UnwrappedComponent"></component> That requires you to create 2 new components (which unlike React, will nee
by scq 5y ago
> <component :is="condition ? 'WrappedComponent' : 'UnwrappedComponent"></component>
That requires you to create 2 new components (which unlike React, will need to be in separate files if you're using SFCs) and pass down all the props another layer.
In the end, I got around it by implementing a "passthrough" component so that you can then do
<component :is="condition ? 'Wrapper' : 'passthrough'>...</component>
but that is far from ideal.
> Not only the react blob is impossible to scan
Formatted properly, I don't really find the React example any harder to read.
Your Vue example puts v-for and v-if on the same element, which is confusing - which is evaluated first? (IIRC, the answer depends on which version of Vue you are using).
> it will be different depending of the dev who coded it, because there is no enforced patterns
That applies to the rest of your codebase too, though. It's up to your team to decide on patterns and enforce them through linting, code review, and automatic formatting.
Also, both of your examples are missing `key`, though React will warn you about it and Vue will not.
- ROARosen 5y ago> Also, both of your examples are missing `key`, though React will warn you about it and Vue will not Vue will warn when you're missing a key on the loop. >That requires you to create 2 new components (which unlike React, will need to be in separate files if you're using SFCs) Your components don't need to be in separate files even when using SFC's. Given 'component' can be as simple as adding to any Vue Component or SFC (when adding it to parent component option): <script> const myComponent = { props: ['myProps'], template: ` <div></div> ` } </script>