SwiftUIMidMCQ

What is `LazyVStack` vs `VStack` — when does it matter?

Test your knowledge:

Explanation & Code

Answer: VStack renders all its children immediately. LazyVStack only renders views as they become visible on screen — essential for large lists.

Code Example:

// VStack — all 1000 rows created immediately
ScrollView {
    VStack {
        ForEach(0..<1000) { i in
            ExpensiveRow(index: i)  // all 1000 created at once ❌
        }
    }
}

// LazyVStack — only visible rows created
ScrollView {
    LazyVStack {
        ForEach(0..<1000) { i in
            ExpensiveRow(index: i)  // only ~20 visible rows created ✅
        }
    }
}

Rule of thumb:

  • Use VStack for small fixed lists (under ~50 items)
  • Use LazyVStack inside ScrollView for dynamic or large data sets
  • List uses lazy loading automatically

Rate your understanding:

Ready to practice more SwiftUI?

Test yourself with our interactive quiz mode or browse all curated questions for this topic.