I want to test the code below in live preview, but it seems not to work. In simulator, the button can change the text well, but not in live preview. How to fix it? Thanks in advance.
Code Block import SwiftUI struct PreviewOnchangeTest: View { @Binding var toggle: Bool @State var text = "nice" var body: some View { VStack{ Text("\(text)") .onChange(of: toggle, perform: { value in text = toggle.description }) Button(action: {toggle.toggle()}, label: { Text("change") }) } } } struct PreviewOnchangeTest_Previews: PreviewProvider { @State static var toggle = true static var previews: some View { PreviewOnchangeTest(toggle: $toggle) } }