Swiftui state variable count lost what it stored

when I click onTapGesture event to setup

self.showDetailView = true self.count = 5

the sheet will popup, but the self.count always be 0, not be 5. so the code Text(“5555”) will never be hit.

it seems state variable count lost what it stored.

import SwiftUI

struct ContentView: View {
@State var showDetailView = false
@State var count = 0
var testArr = [1,2,3,4,5]
var body: some View {

    NavigationView {
        List(testArr.indices){ indice in
            Text("row num \(indice)")
                .onTapGesture{
                    
                    self.showDetailView = true
                    self.count = 5
                    }
            
            }
            .sheet(isPresented: self.$showDetailView) {
                if self.count == 0{
                    //  print("count = 0")
                }
                if  self.count == 5{
                    Text("5555")
                }
            
            }
        
            .navigationBarTitle("Your Reading")
    }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Hi,

could you please tell which chapter this code is from?

Thanks!

i have purchased this swiftui book, but above code, just for my own learning code, just few lines, dont know how to figure it out, so post here, to see if someone can help.