Why this code cause this warning?

#for value in range(1, 8) {
  context repr(here().position().x)
}

layout did not converge within 5 attempts
Hint: check if any states or queries are updating themselves

1 Like

You are creating 7 pieces (red boxes here) where the seventh box’s text depends on the text in every box before it on the same line:

It runs out of iterations when trying to layout this, since the x position of each box needs to resolve to the actual text, which influences the x position of the next box.

In general to avoid the layout iteration warning, try to make every element be able to independently resolve its layout and position, so that there are no long dependency chains. In this example, either measure and set box widths dynamically, or use fixed box widths around each text.

2 Likes