-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Support components
obj in functional components (fix #7492) (fix #6872)
#8143
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
base: dev
Are you sure you want to change the base?
Support components
obj in functional components (fix #7492) (fix #6872)
#8143
Conversation
merge latest
Adds support for the components hash to be used in functional components fix vuejs#7492
components
obj in functional components (fix #7492)
👍 |
In which circumstances will you need this functionality? Just curious! |
@kushalmahajan we (the projects i'm involved with) tend to write all components in single vue files with template blocks and avoid render function as much as possible since without JSX it could become quite messy very fast. Here's the typical use-case :
If i'm not mistaken, this would be the only reason for such a thing. |
@y-nk. I see! Same like the normal components property on non-functional Vue components. If it helps, then I would like to mention that if you write functional components with render functions, the components property is not required for it to work. I don't know the underlying reason but it's definitely not mandatory there. Plus, I am writing just .js file only so the advantage one gets is full fledged dev tooling, which .vue is still not offering , apart from just doing function without template as a component. Below is an example of a simple dropdown component I built
|
chore(types): add components option for functional
Can this go into 2.6.1? Please? |
This would be very handy, sometimes I separate some components that contains just some svg icons using vue-svg-loader and has no additional logic within them. I wish I could write them as functional. Writing them with render function is unpractical in larger teams with varied skill levels. I read in a comment in another PR that in v3 stateful components will be much faster to initialize, and I agree that we should keep functional components minimal and don't add all the options that a stateful component has. But using other components is great for composition and, in my opinion, would be a great addition and allow for cleaner components. Also we might not be able to migrate all precious codebases to v3 when it is released, so the faster initialization times and memory gains we could have now with this is much beneficial, in my opinion. |
Some new info on Evan's vision of functional components: https://github.com/vuejs/rfcs/blob/functional-async-api-change/active-rfcs/0000-functional-async-api-change.md Still a proposal but based on this, it seems more unlikely this will ever get merged. |
Based on the information in the above link, it's best to avoid future use of the Even though he states that there will be a graceful degradation of this feature. |
The v3 the difference between functional and regular components won't be as significant performance wise. So, you can keep writing templates, it may be easier to refractor to functional components now and maybe again in v3 |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
Fixes #7492 #6872 (duplicates)