-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discussion] Add JSX support to simplify render function components and Vue 2 + Vue 3 support #6024
Comments
It depends on what exactly you mean. But if you mean real JSX, like bringing React syntax¹, then I would vote against this, as it brings a new syntax that adds a new layer of complexity and is very uncommon across the Nextcloud ecosystem. I do not think that it is so important to do anything here for the Vue 2 vs Vue 3 part². For NcButton there is no good reason to not use template + script, but actions are a bit more trickier. This is unrelated but I would even propose that we refactor actions into two components: A simple popover menu without inline button support - this will allow custom components for grouping. And ¹ with React style I mean JSX like: export default {
....
methods: {
checkStatement(){
if (this.user.age > 18) {
return <div> Welcome, { this.user.name }</div>;
}
}
},
...
} ²As I am still in hope that we migrate everything soon ( 🤞 ) and can bury Vue 2 soon (so only need to provide bug fixes, like with v7 currently). There is no (unpaid) support for Vue2 anymore, its really time to push this. |
What title says - use JSX syntax for render-function.
Benefits:
|
But this is not a "React syntax". JSX is a commonly used JavaScript syntax sugar. It is used by many frameworks, including modern like Solid.js, MDX syntax, and Vue. If you mean an approach - using render function instead of template - we use it already. JSX doesn't change this fact, it only makes it less painful and better in performance. |
I have no idea how to do it in And in We can think about it, but this is something for future with huge changes in many places. Currently I only propose to makes the current state simpler and more performant. |
I don't think raw render-function API is simpler. It's even harder. And it looses compile-time optimizations. And you have to learn 2 APIs for Vue 2 and Vue 3. Learning JSX itself is not a big deal. If you already know render function api, then learning JSX is learning sugar with just 2 things. |
It depends on what you consider complexity. The problem there is the router link. But because you need to conditionally wrap it inside a router-link you need to either duplicate it or split it in two (three) components. <RouterLink v-if="isRouterLink">
<ButtonImplementation />
</RouterLink>`
<ButtonImplementation v-else /> or add a third (empty) dummy component <component :is="isRouterLink ? 'router-link' : EmptyDummy">
<ButtonImplementation />
</component>`
Yes on that I agree :)
But it is not used, so it is new and only required for this place. So you expect people to learn it for two places, that can (more or less) easily just rewritten as templates. Some time ago I started doing exactly that: Migrate NcButton to a template, now you motivated me to finish that 😅 |
The proposal is not about migration
<template> -> JSX
but fromrender: () => h(tag)
torender: () => <tag />
in the components already implemented via render functions.Adding JSX support allows:
Required steps:
NcActions
,NcButton
The text was updated successfully, but these errors were encountered: