live preview problem

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)
    }
}

As far as I know, SwiftUI cannot manage static @State variables properly.

Please try this:
Code Block
struct ContainerView: View {
@State var toggle = true
var body: some View {
PreviewOnchangeTest(toggle: $toggle)
}
}
struct PreviewOnchangeTest_Previews: PreviewProvider {
static var previews: some View {
ContainerView()
}
}


live preview problem
 
 
Q