8.6 · Lists, ForEach and NavigationStack

Lists and navigation are where identity, state and performance meet. A list shows identified data, and navigation is state you can read and change.

Mental model. A list is data with stable ids. Navigation is a value (a path) that you own, so you can push, pop and restore it from code.

Showing collections

<code>List</code>, <code>ForEach</code> and lazy stacks.

  1. How do List, ForEach and the lazy stacks differ, and what do they need from your data? 8.6.1 · L2
    ForEach is not a container: it generates a view per element of a collection and needs an identifier for each, either because the element is Identifiable or…

Moving between screens

<code>NavigationStack</code> and <code>NavigationPath</code>.

  1. How does NavigationStack work, and how do NavigationPath and navigationDestination fit together? 8.6.2 · L3
    NavigationStack shows a root view and a stack of pushed destinations, and, unlike the older NavigationView, its stack is state you can read and write. You give…

More in SwiftUI