FB11835461
In real world applications it makes more sense to use ObservableObject referrence type to drive navigation than simple value type. The example below demonstrates that.
Problem is that for some reason NavigationStack will create memory leak if path is set to empty array after navigating any number of times through stack. All view models that were created in process will be retained in memory even though path is set to [].
Same problem occurs if we set path to empty array and just swap whole NavigationStack with any other view still all objects created will be retained in memory.
There is workaround that I will show bellow to fix this but it is still very buggy behaviour IMO.