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.
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.
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.
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
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
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 ?
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.
Actually there are functional components in Vue. The document says
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.