Modifying state during view update

You're inside one of View.body function. SwiftUI is gathering data to display your view. You shouldn't update data, especially @State during this time, it will cause unexpected result.

Instead, use one of event handlers like onAppearInput and Events.