Post #1695280
2026-04-26 06:28 UTC
SwiftUI's List is only lazy when SwiftUI can determine how many views a ForEach element resolves to without evaluating the closure.
Two common patterns prevent this:
- Using an `if` statement inside ForEach
- Wrapping rows in AnyView
In both cases, SwiftUI evaluates the ForEach closure for every element before any rows are displayed.
You can learn more in the free sample chapter of my book "The SwiftUI Way": https://books.nilcoalescing.com/the-swiftui-way/building-a-performant-and-stable-interface/maximizing-the-performance-of-dynamic-lists/
#SwiftUI #iOSDev
Replies (0)
No replies.