r/javascript • u/adstwlearn • Jun 28 '18
The exact same app - 1 version made with React, Redux, and React-Router The other made with Vue, Vuex, Vue-Router. Good if you want to see both worlds. User Auth with JWT, note CRUD actions, Koa (Node) backend. MIT license.
https://johndatserakis.github.io/koa-react-notes-web/
459
Upvotes
54
u/adstwlearn Jun 28 '18 edited Jun 28 '18
Great question. For me, it's Vue.
All in all - I did like React. Not too hard to pick up. It's complete, and has a great community. The thing is, it seems like there's less batteries installed. That can be a plus at first, but after you sorta get the idea of how things work, it seems like you're just writing more code then needed.
Like with React-Router and how, if a component was not a direct descendant of a
Switchstatement main route definition, then it didn't have access to thehistoryprop - and I had to wrap it with thewithRouterHOC. That was just a bit funny - although I do like how some components are truly dumb vs smart - I guess that's the intent. It's just a bit different from having the$routeralways available to use throughthis.$routerin Vue. Small things like that stood out.The strangest thing for me in React was the render function. In Vue it's just so easy to loop over data and spit out elements or show/hide data based on state/store variables - in React it felt pretty strange to have to create my notes loop outside of the render.
In Vue, if you want to show or hide something - just use
<div v-if="myVariable">Lorem...</div>and it'll be based of yourmyVariabletruthiness. In React it seems like you have to do:It's a little more verbose, and doesn't support that instant-helper looping that Vue can manage. But of course, after I familiarized myself with how to do those normal little things, it didn't seem too odd. It's like, ok, whatever - that's just how you do that.
One other thing - the redux and react dev tools are definitely not as nice as the Vue tools - from the style, to having to open a huge tree of elements just to see a component's state - it made it a bit tough to get a view of my app's variables. I may be missing something here though or using a version that isn't the current community standard.
I definitely like React, and I do feel it was important to spend a solid month with it to learn its intricacies, but I do think I'll be using my Vue setup going forward for most things. It's less code and a simpler coding experience with helpers that make sense and are just magical enough that they're helpful, but not too magical that I lose track of what's actually going on.