DEV Community

Discussion on: React or Vue or Something New?

Collapse
 
revskill10 profile image
Truong Hoang Dung • Edited

It depends on your favorite paradigm. ReactJS code tends to be functional. Let me tell you the way how a React component get rendered on browser.

An application needs a currentUser, so i create a withAuth higher order component.
A component needs to authorize that currentUser to display/allow/disallow action on that component, so i create a withPermissions hoc.

A page needs a layout, so i create a withLayout hoc.

A component might get rendered differently based on current route, so i create a withRouter hoc.

In the end, your page is rendered as

compose(
withAuth,
withPermissions,
withLayout,
withRouter
)

I must say, i love this style of application design and implementation also.
In Vue, i couldn't, because the way to code Vue is to use a Vue component, not function.

Or am i missing something in Vue ?

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

For the specific example you've given, my first instinct would be to check out Vue mixins. The react team has a different philosophy about mixins and prefer compositions as you've shown. Could read Dan Abramov's "Mixins considered harmful" article for their perspective. On the other hand, The Vuetify library is an interesting Material implementation that relies heavily on Vue's mixins.

Collapse
 
ozanmuyes profile image
Ozan Müyesseroğlu

Actually there are functional components in Vue. The document says

Since functional components are just functions, they’re much cheaper to render.
(snip)
They’re also very useful as wrapper components. For example, when you need to:

  • Programmatically choose one of several other components to delegate to
  • Manipulate children, props, or data before passing them on to a child component
Collapse
 
proticm profile image
Milos Protic • Edited

Hi, your question was already answered by Ozan. As you can see, Vue does support JSX as well. And I agree with you that everything is in personal preference when you have great frameworks to choose between.