[Xcode 12 beta.1] @State does not project a value correctly that set from an event handling closure.

While I'm trying to use SwiftUI on Xcode12 beta.1.

I found @State does not work correctly under the specific case.

That issue will appear in following:
@State var selectedValue get a new value from onTapGesture of something view.
And then, attempt present sheet.
That sheet presentation needs the view that contains selectedValue

selectedValue must have the set value, because it will run afeter modified selectedValue. but it does not.

Code Block swift
struct ContentView: View {
 @State var selectedValue: Int?
 @State var isPresented = false
 var body: some View {
  VStack {
   Text("Tap this number")
    .onTapGesture {
     selectedValue = 1
     isPresented = true
    }
  }
  .sheet(isPresented: $isPresented) {
   Text(selectedValue!.description)
  }
 }
}


But if we do this, the issue solves.

Code Block swift
struct ContentView: View {
 @State var selectedValue: Int?
 @State var isPresented = false
 var body: some View {
  VStack {
Text(selectedValue.debugDescription)
   Text("Tap this number")
    .onTapGesture {
     selectedValue = 1
     isPresented = true
    }
  }
  .sheet(isPresented: $isPresented) {
   Text(selectedValue!.description)
  }
 }
}


I just added a line that reads the value of selectedValue


I've been having this same issue with almost all of my state with no way of fixing it except displaying the state in the view (which is far from ideal)! I've sent in a bug report with Feedback Assistant and I suggest you do the same!
Thanks for posting this! I don't know how long it would've taken me to figure this out. Still a problem in beta 4.
I am also having this bug. I can't believe this is NOT resolved in Xcode 12 which is released to the public. Bloody ridiculous!
I think I just ran into the a same issue: https://developer.apple.com/forums/thread/660976
So it seems the issue is still in Xcode 12 and Xcode 12.2 beta.
[Xcode 12 beta.1] @State does not project a value correctly that set from an event handling closure.
 
 
Q