Replies: 2 comments 6 replies
-
Does it actually work? Alpine runs on the generated output and your browsers won't really parse duplicate attributes |
Beta Was this translation helpful? Give feedback.
4 replies
-
Theres no reason you can't. Just be aware that if the final element ends up with 2 that x-component thing isn't part of Alpine... |
Beta Was this translation helpful? Give feedback.
2 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
For simplicity, let's say we have the following component:
We use this component everywhere but there's one place where we need some more functionality. We need to keep track of its value in an Alpine store. The simplest way to do this would be to copy the component. But as it's a pretty complicated one with lots of options we prefer not to.
Turns our that you can add a second x-init by passing it as an attribute.
Which gets rendered into:
But that might be wrong? Or perhaps there are better solutions? Are there any downsides of having x-init twice in your component?
Beta Was this translation helpful? Give feedback.
All reactions