I ended up using a third party WebSocket library.
It would be good if we were able to change the Host header of the URLRequest when the URL itself contains an IP number instead of a DNS name.
Post
Replies
Boosts
Views
Activity
I'm sorry, I should have clarified that the code is just an example showing the problem. The code I have in my app is a lot more complex so I reduced it into a much more simple example. The "Add" button in the sample is just a simple way to force an updated on the main view. I understand that removing the binding into the SubView stops the problem but in the real app I need that binding.
I have now fixed the problem by implementing the workaround using a boolean to keep track of when the view receives an onDisappear().
But the question remains: why does SwiftUI keep updating a view that is no longer showing on screen? There's something fundamental about the lifecycle of a SwiftUI view that I don't understand.