Preferences

LazyVStack and ScrollView don't scale (no cell reuse / no unloading). The only option is List which has different behaviors and performance characteristics on macOS including issues with eager rendering

To be fair a LazyVStack handles cell reuse and unloading automatically which is why offscreen content that was previously viewed further back on the list will only maintain the root level state (children in the view hierarchy may and will lose state in order to save memory and energy). How that data is loaded and how you key off Identifiable is also important.

Apple’s own documentation discusses this in detail and for large data sets recommends the Lazy approach. If you’re using List you’re in for some issues.

Where do you see that it does cell reuse? It does not... Their docs only talk about lazy loading, not reuse or unloading, eg: https://developer.apple.com/documentation/swiftui/creating-p...

This is also why LazyVGrid/LazyHGrid are unusable as replacements for UICollectionView

Yes you can replace SwiftUI with UIKit + AppKit - replace the navigation, the text rendering, the text editing, the collection views, etc.

edit: Your link is all about how to use List

I’m on a phone which means digging through Apple docs or WWDC-ascii isn’t fun. But for my recent Insta-like infinite feed on iOS this was very helpful:

https://fatbobman.com/en/posts/tips-and-considerations-for-u...

Your link is all about how to use List

Also... Funny that I'm getting downvoted for correctly pointing out that LazyVStack doesn't reuse or unload views. It's so obvious that they should, that no one can believe they don't.

There are additional links and details about LazyVStack highlighted in the content. I thought the top level article focused on Lists would be more helpful for you.
I followed those links and it agrees with my initial post that LazyVStack does not reuse or unload, and confirms that the only choice for large data sets is List (focused on iOS)
Well the good news is you can keep using UICollectionView or MyFancyReuseView anywhere in the stack or tree of SwiftUI.

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal