Error in photo gallery app

Hi Francis, I’m doing the photo gallery app, and in lesson Menu page, I run into this error ( tried StackO but not working) when adding $openMenu in .sheet method.
Accessing State’s value outside of being installed on a View. This will result in a constant Binding of the initial value and will not update.`
The code is:

.sheet(isPresented: $openMenu, content: {

Pls let me know how to fix so I can proceed. I’m on Xcode 14.3.


openMenu should be a @State variable declared at the top just inside the ContentView struct above the declaration of the var body: some View { property. Francis declared it like this:

@State var openMenu: Bool = false

1 Like

Oh what a silly mistake to make! Thanks Chris, I don’t think I would have registered that at all! I automatically thought it would be in the body. I think the init method for dark theme misled my eyes :sweat_smile: