SwiftUI NavLink Dismiss

How do I create an action that occurs when a child view (showing through a NavigationLink) is dismissed? I am trying to pass a value, but can't create a function to use the received value.

Thanks in advanced.

Answered by Mcrich23 in 696453022

.onDisappear did not work, but .onAppear did. Thx so much!

Accepted Answer

To perform an action when a View disappears, you can use onDisappear

func onDisappear(perform action: (() -> Void)? = nil) -> some View

To update a value from an enclosing View, you could use a Binding.

Accepted Answer

.onDisappear did not work, but .onAppear did. Thx so much!