struct NavStack: View {
@AppStorage("userid") var userid: Int = 0
@State var memes = [MemeModel]()
@State var path = NavigationPath()
var physique: some View {
NavigationStack(path: $path){
ScrollView(.vertical, showsIndicators: false){
LazyVStack(spacing: 100){
ForEach($memes, id: .memeid){ meme in
MemeView(memes: self.$memes, memeid: meme.memeid)
}
}
}
.onAppear{
memes.append(MemeModel(memeid: 1, title: "meme1", pic: "bla.jpg"))
memes.append(MemeModel(memeid: 2, title: "meme2", pic: "joo.jpg"))
memes.append(MemeModel(memeid: 3, title: "meme3", pic: "das.jpg"))
memes.append(MemeModel(memeid: 4, title: "meme4", pic: "fsf.jpg"))
memes.append(MemeModel(memeid: 5, title: "meme5", pic: "asd.jpg"))
memes.append(MemeModel(memeid: 6, title: "meme6", pic: "dfvr.jpg"))
memes.append(MemeModel(memeid: 7, title: "meme7", pic: "fsfdf.jpg"))
memes.append(MemeModel(memeid: 8, title: "meme8", pic: "axaxe.jpg"))
}
}
}
}
struct MemeView: View {
@Surroundings(.dismiss) var dismiss
func closeThisView(){
DispatchQueue.important.async {
self.dismiss()
}
}
@AppStorage("userid") var userid: Int = 0
@Binding var memes: [MemeModel]
@Binding var memeid: Int
var physique: some View {
VStack(spacing: 20){
Textual content(String(memeid))
NavigationLink{
Feedback()
} label: {
Textual content("feedback")
}
}
}
}
struct Feedback: View {
@AppStorage("userid") var userid: Int = 0
var physique: some View {
VStack{
Textual content("feedback view")
}
}
}
struct MemeModel: Codable {
var memeid: Int
var title: String
var pic: String
}
After I faucet on remark
then the app freezes. It solely occurs when the deepest youngster view (feedback
) incorporates AppStorage
worth and it really works once I take away it. After I simply use MemeView
as NavigationLink (so with out having any NavigationLink
inside MemeView
) then freeze would not occur.
How one can repair this? Any workaround?
Ofc I’ve seen the opposite questions on freezing when utilizing NavigationLink, additionally exterior Stackoverflow, however not one of the solutions are serving to.