Recall & Review
beginner
What is a LazyVStack in SwiftUI?
A LazyVStack is a vertical stack view that loads its child views only when they are about to appear on screen, improving performance for long lists.
Click to reveal answer
beginner
How does LazyHStack differ from a regular HStack?
LazyHStack loads its child views lazily, meaning it creates views only when needed during horizontal scrolling, unlike HStack which creates all views at once.
Click to reveal answer
intermediate
Why use Lazy stacks instead of regular stacks in SwiftUI?
Lazy stacks improve app performance and reduce memory use by creating views only when they are visible, which is helpful for long or scrollable lists.
Click to reveal answer
intermediate
Can you nest LazyVStack inside LazyHStack? Why would you do this?
Yes, nesting LazyVStack inside LazyHStack allows creating complex scrollable layouts that load views lazily both vertically and horizontally, saving resources.
Click to reveal answer
beginner
What happens if you use LazyVStack without a ScrollView?
Without a ScrollView, LazyVStack behaves like a regular VStack because all views fit on screen, so lazy loading has no effect.
Click to reveal answer
What is the main benefit of using LazyVStack in SwiftUI?
✗ Incorrect
LazyVStack improves performance by creating views only when they are about to appear on screen.
Which container is needed to enable scrolling with LazyHStack?
✗ Incorrect
LazyHStack must be inside a ScrollView with horizontal scrolling enabled to load views lazily.
What happens if you put a LazyVStack inside a ScrollView?
✗ Incorrect
LazyVStack inside a ScrollView loads views lazily as you scroll vertically.
Which of these is NOT a feature of LazyHStack?
✗ Incorrect
LazyHStack does not automatically add padding; padding must be added manually.
Why might you choose LazyVStack over VStack?
✗ Incorrect
LazyVStack improves performance by loading views only when needed, useful for many child views.
Explain how LazyVStack improves app performance compared to VStack.
Think about how views are created and shown on screen.
You got /4 concepts.
Describe a scenario where using LazyHStack inside a ScrollView is beneficial.
Imagine a photo gallery you scroll sideways.
You got /4 concepts.