Skip to content

Error: Dynamic root HTML element id attribute

Taylor Hunt edited this page Aug 2, 2019 · 2 revisions

The id for the outermost HTML element of a component must be static. Components are uniquely identified by their id; if that id changes during a re-render, then diffing and patching will break.

Erroneous code

$ var id = input.id;

<div id=id/>

Fixed code

$ var id = input.id;

<div>
  <div id=id/>
</div>

If you don’t care about the exact value of the id, you can also have Marko generate one for you with id:scoped:

<div id:scoped=""/>