Clay's algorithm actually does many passes, that doesn't mean it invokes the UI function multiple times. You are allowed to retain state during computation.
Jetpack Compose splits this into measure and layout passes, and running either pass twice crashes the UI. They can do this because they are faking immediate-mode on top of a retained-mode layout tree, sort of like React.
Layout computation is always awkward in immediate guis. You have to do an extra pass or throw away a frame.
Replies (2)
Here's a cool explainer video:
https://www.youtube.com/watch?v=by9lQvpvMIc