I have a view that displays multiple images fetched from Firebase in a VStack. Each image is a button, the button opens a sheet and it displays the image and text that goes with it. When I dismiss the sheet and press on a different image the same data comes up. How do I refresh these paramaters
VStack View with images as buttons:
@State var dic = OrderedDictionary<String, UIImage>() VStack (alignment: .center) { ForEach(dic.keys, id: \.self) { dicObject in Button { showingSheet.toggle() } label: { Image(uiImage: dic[dicObject]!) .resizable() .frame(width: 300, height: 400) .cornerRadius(20) } .sheet(isPresented: $showingSheet) { GalleryViewSpecific(image: dic[dicObject]!, url: dicObject) } } } View specific image view used by .sheet
//@State var image: UIImage @State var image: UIImage @State var url: String @Environment(\.dismiss) var dismiss var body: some View { ScrollView { VStack(alignment: .leading) { Button("Press to dismiss") { dismiss() } .font(.title) .padding() .background(.black) Image(uiImage: image) .resizable() .frame(width: 300, height: 400) .cornerRadius(20) Text(url) .foregroundColor(.white) } } .background(Color.black) } 
sheetoutside theForEachand usesheet(item:)instead ofsheet(isPresented:)struct ContentViewthat someone can paste into Xcode and run. Please take a look at minimal reproducible examplesheet(item:)form I suggested. You'll set theitemto your object inside theButtonactionForEachis not a for loop