I was playing around with SwiftUI and want to be able to come back to the previous view when tapping a button, the same we use popViewController inside a
Modify your BView struct as follows. The button will perform just as popViewController did in UIKit.
struct BView: View {
@Environment(\.presentationMode) var mode: Binding
var body: some View {
Button(action: { self.mode.wrappedValue.dismiss() })
{ Text("Come back to A") }
}
}