-
Notifications
You must be signed in to change notification settings - Fork 648
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
passing data from state in the include tag #705
Comments
First off, the following is not valid: < input id=state.id /> That prevents the HTML tag from being parsed. The initial space after the <input id=state.id /> That is a separate issue though... It is somewhat of an odd restriction, but the ID for the root HTML element of a UI component needs to be static and (we need to provide a better error message... sorry about that!). The reason for this is that a UI component is uniquely identified by its ID and if the ID changes during a re-render then diffing/patching will break. Wrapping everything in a class {
onCreate() {
this.state = { id: 1}
}
}
<div>
<input id=state.id />
<include('./include-target', {id: state.id}) />
<include('./include-target') id=state.id />
</div> Typically, you want to always avoid assigning an Marko does not currently correctly handle multiple dynamic top-level HTML elements correctly in all cases. We are working on a fix for that. |
@austinkelleher @mlrawlings, can either of you look into improving the error message if the ID for the top-level HTML is dynamic? Thanks. I'm keeping this issue open because we are not providing a good error message to the user. |
That's great, worked straight away. Thanks for the quick response. The space after the input was a typo. Will avoid using id in the future :) |
@patrick-steele-idem I'll get to working on this either later tonight or tomorrow. |
Fixes #705 - Throw error when the root HTML element has a dynamic id …
…attr Revert "Fixes #705 - Throw error when the root HTML element has a dynamic id …"
…d has a dynamic id attribute.
Fixes #705 - Throw error when the root HTML element is a component an…
Bug Report
Context
component state is out of scope inside the include tag
Expected Behavior
pass state variable to included template
Actual Behavior
state is undefined
Steps to Reproduce
I have a component something like
Stack Trace
The text was updated successfully, but these errors were encountered: