Alpine v3 component getting initialised twice on Phoenix LiveView page #1998
Replies: 5 comments 4 replies
-
Unfortunately, I have the same issue. Getting dupes when LV gets an update. Tried this with Alpine 3.5. |
Beta Was this translation helpful? Give feedback.
-
Same here. I found this discussion after opening a liveview bug. |
Beta Was this translation helpful? Give feedback.
-
Does this workaround help you?
|
Beta Was this translation helpful? Give feedback.
-
It should be fixed by #2376 |
Beta Was this translation helpful? Give feedback.
-
Maybe related: but I've noticed that Alpine doesn't "see" a x-data attribute when LiveView replaces some of the attributes of an already existing element. For instance, you have this HTML output before LV sends an update:
And gets replaced by:
Anybody also noticed this? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello folks,
It seems I have encountered a weird issue when doing live_redirect to a LiveView page which has AlpineJS V3 component.
Environment:
Here is the trimmed down version of the component which is able to reproduce the behavior. The server counter is a simple socket assign.
Expected Behavior: x-data and x-init expressions to be called only once as nothing is changing in component when coming directly to the page or via live_redirect. This indeed happens (as shown in the following screenshot) when coming to the page directly but not when coming to the page via live_redirect.
Whats happening: Both x-data and x-init are getting called twice when coming to the page via live_redirect which in turn is creating 2 data proxies in component. I am able to see these 2 proxies by doing this:
This issue is stopping me from upgrading from v2 to v3. Am I missing something here or could it be a bug? Will really appreciate any help with this. Thanks
Beta Was this translation helpful? Give feedback.
All reactions