24.4 The onChange Modifier
In basic terms, the onChange() modifier should be used when an action needs to be performed each time a state changes within an app. This, for example, allows actions to be triggered each time the value of a state property changes. As we will explore later in the chapter, this modifier is also particularly useful when used in conjunction with the ScenePhase environment property.
To experience the onChange() modifier in action, begin by editing the SecondTabView.swift file so that it reads as follows:
import SwiftUI
struct SecondTabView: View {
@State private var text: String = ""
var body: some View {
TextEditor(text: $text)
.padding()
...