SwiftUI's onChange is deprecated in iOS 17
With iOS 17, SwiftUI’s old onChange(of:perform:) is deprecated. Two new signatures arrived in its place:
- A plain version whose closure takes no parameters.
- A version giving both old and new values:
onChange(of:) { oldValue, newValue in ... }
You can also use the initial parameter to fire on first appearance without waiting for a change. The new signatures remove the old API’s ambiguity of “the value changed — but from what to what”.