3 ms·
I use and like both. Vue has single file components with isolated CSS styles built in by default. I really don't like the CSS conventions in the React world. S
by adam_arthur 5y ago
I use and like both.
Vue has single file components with isolated CSS styles built in by default. I really don't like the CSS conventions in the React world. Seems everybody has settled on CSS modules, but I'd rather not have two files that represent a given component. You can of course inline styles and use alternative approaches, but none come close to ease of use and readability of Vue scoped styles, while preserving component level isolation. I know this because I've spent hours trying to replicate it in React. It's odd that mixing html components into JS via JSX (which I agree with) caught on, yet the same is often not done for CSS. Conceptually would like everything in one file, and with proper isolation (not affecting child components)
More subjectively, I feel React has a lower floor for writing poor quality/hard to reason about code.
Not a problem for personal projects, but at larger companies it's not as great. I'll have to spend some time thinking about and quantifying the specifics, but always seems to be that react projects end up being more difficult to decipher, all else equal. Not due to framework paradigms, just the collection of conventions and style that pushes you towards. One of the things is that in Vue there's a forced separation between markup and logic oriented code. This is best practice in react too, but easier to mix by mistake due to prevalence of JSX.
Also if/else statements in JSX being done via ternary reads very poorly in my opinion. I have seen third party components for this, but not sure why there's not a native implementation. Fragmenting your view code and assigning to variables/JS if else does not read well. Ordering of markup in Vue always matches ordering it will be evaluated in. Whereas in a react codebase there may be many variables or components declared within the same file and stitched together later, which requires the reader to reverse engineer what the evaluated code will look like.
React does have greater flexibility for mixing UI composition with scripting logic, which comes in handy for particularly complex use cases, but is often not needed. Of course you can use JSX with Vue as well, just not very conventional.
Finally, Vue is implementing all supporting major features from a first party perspective, whereas react projects tend to be more of a patchwork of open source components. E.g. static site generation, state management, cli, routing. I believe some packages like redux got formally adopted, but Vue is approaching from single implementation/first party first. Which leads to more consistency between projects in ecosystem.