I have a basic list in my first View as Follows:
func buildList(sections: [Client]) -> some View {
let list = List {
ForEach(sections) { client in
Section(header: Text(client.name)) {
ForEach(client.projects) { project in
NavigationLink(destination: BuildsRouter.build(forProject: project)) {
HStack {
Text("Test \(project.id)").fontWeight(.ultraLight)
}
}
}
}
}
}
return list
}
I'm using NavigationLink
to provide the details view for my Project
object.
Thing is, when I make a Memory analysis graph I can see that BuildsView
( created from BuildsRouter.build(forProject: project)
are created before I actually tap the navigation Link.
Question: Is there any way to create the details View once the link is tapped?
True, I wrote a blog post on this. You can wrap the destination views in a Lazy Container as a workaround. Update: From Xcode 11.4.1 NavigationLinks are lazy by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With