Replies: 2 comments
-
|
There's no way for Alpine to know the difference between a data component and a local variable, and a data component has always priority. |
Beta Was this translation helpful? Give feedback.
-
|
So, whether ideal or not, the components defined with Mainly because that would be a standard expectation that they are the thing most likely to be referenced. So your example of It's just impossible to have to be the number being passed to the datafactory. Alpine is still just JS. And you can't have 2 variables in scope with the same name. do the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm encountering unexpected behavior when passing a variable from one component to another using Alpine.js.
Instead of passing the actual value
+30:6979999999to the phone component, Alpine appears to pass the entire component definition created withAlpine.data('phone'). This leads to unexpected results.Is this a known issue or expected behavior? Is there a better recommended way to pass primitive values like strings to an Alpine component?
Renaming
Alpine.data('phone')to something likeAlpine.data('phoneComponent')seems to resolve the issue.Alternatively, using
x-data="phone($data.phone)"instead of justphone(phone)also works.Would appreciate clarification or guidance on whether this is a bug or a naming conflict limitation.
Beta Was this translation helpful? Give feedback.
All reactions