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
2
u/jkoudys Jun 29 '18
Does "less code" really imply a "simpler coding experience", though? As a 3rd-party reading your code, I look at something simple like your App.vue, and look at how many modules are implied to have loaded without actually specifying its source. The
<footer-main>for example, requires that your router.js is loaded, which registers aVue.component(essentially a global) sofooter-mainis your Footer.vue. Not only is it harder to reason about, but it limits us if we want to code-split the chunk too.If you're using direct imports, every missing one shows up as a big squiggly red line from static-analysis in my editor long before runtime. Every non-trivially small component can be included via an
import(), so it only gets its chunk loaded when I decide it's needed.There's a lot more that forgoing pure ecma for a micro language hinders you for too. Dead-code elimination is basically impossible, both because Vue.component and router are essentially globals, and because so much of the control logic (e.g.
v-if) is in microlanguage. There's the complexity of needing to learn, write, and reason in multiple languages at once (both harder to build and reason about -- with React and emotion, I don't need a single line of CSS, or to write any HTML beyond the tiny boilerplate react-create-app makes).Don't think I'm being too critical - super happy you wrote this and released it to everyone. I do think a lot of your problems with react are based more in familiarity with vue, and React not being enough like vue isn't really a flaw. Some of your criticisms of individual libs (especially router) are pretty spot on, but you're also not following some basic patterns that React devs (especially the FP-loving ones) routinely use. e.g. out of array methods
map,reduce,filter,find,Array.from,[... ], etc., I find only a singleArray#map, which is pretty unusual for a React app. React's all about passing in the same collection as a prop to different components, and rendering them differently, e.g. a collection of restaurants could be mapped to a bunch of pins on a<GoogleMap>in one place, a text list in your<Itinerary>somewhere else,Vegan options: {restaurants.filter(({ cuisine }) => cuisine === vegan).length}in another component, etc.