Thirdly, I'm not sure what you mean when you say that @ViewBuilder is "not valid SwiftUI". It's a public piece of the API which has a very specific effect. My understanding is that my usage of it here is exactly the type of situation where explicitly spelling out @ViewBuilder (instead of allowing it to be inferred on the body property of a View) is recommended. What it allows for is producing views using language constructs like if and switch.
Post
Replies
Boosts
Views
Activity
Secondly, I believe that id: only requires a key path that provides a hashable value that is unique among the displayed elements. The elements I'm passing into the ForEach are the keys of a dictionary and are therefore unique and hashable, meaning that id: \.self is perfectly valid.
I don't think these pieces of advice are correct.
Firstly, I'm aware of which aspect of my code triggers the warning. My question is about why the framework developers chose to flag recursive view updates as a problem, when it seems to me that as long as the recursion is not infinite it would be perfectly coherent code, and also the code currently produces exactly the desired behavior (except for the presence of the warning).
See my reply below, which had too many characters to post as a comment.
Can you clarify how this answers my main question?
Main Question: "Why exactly is it prohibited [to change the state during a view update]?"