how best to compose a component rather than wrap it #10052
Unanswered
oliver-sanders
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Vue community 👋,
I have two components where one wraps the other, adding a little to the template and passing through the props unchanged. I would like to avoid wrapping the component for efficiency reasons and would like to know what's the best practice for doing this.
The Problem:
The reason I use a wrapper is because the component being wrapped is an SVG component, for use within
<svg />
tags. The wrapper, wraps this in<svg />
so it can be used in HTML.Here's a reduced example:
SVGComponent:
HTMLComponent:
This is great for maintenance, as it allows me to reuse the SVG component in HTML without having to duplicate any of the template code, methods, props, etc.
But, this approach is not so good for efficiency, because the HTML component ends up with one reactive component wrapping another reactive component.
This section of the docs outlines the issue:
The Question:
So I would like to find a way to define the HTML component from the SVG component without wrapping it in the hope of achieving both maintainability and performance.
Context:
What approach would you good folks recommend for this?
defineComponent
?defineComponent
solution attempt:Beta Was this translation helpful? Give feedback.
All reactions