I\'m using a NavigationLink inside of a ForEach in a List to build a basic list of buttons each leading to a separate detail screen.
When I tap on any of the list ce
If you have a @State
, @Binding
or @ObservedObject
in MainMenuView
, the body itself is regenerated (menuItems
get computed again) which causes the NavigationLink
to invalidate (actually the id
change does that). So you must not modify the menuItems
arrays id
-s from the detail view.
If they are generated every time consider setting a constant id or store in a non modifying part, like in a viewmodel.