4 ms·
The view layer is meant to be dependent either on application state you provide, or its own internal state if you don't provide any. So for the NavigationLink
by dwaite 7y ago
The view layer is meant to be dependent either on application state you provide, or its own internal state if you don't provide any.
So for the NavigationLink example, there is an isActive parameter which takes a Binding<Bool>. If you set that value as true, the navigation will be made active. Likewise, you can read whether the navigation link is active by reading the bound parameter.
Instead of pushing navigations onto a history object stack, you return a view that represents the nested navigations based on state.
Bindings like 'isActive' are discretionary because the NavigationLink can provide the appropriate (if non-persisted) state if your application logic doesn't care.