onDisappear

Adds an action to perform after this view disappears.

View ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+onDisappear(perform:) in SwiftUI

Declaration

React
compose().onDisappear({
  perform?: (() => void) | null,
})
Swift
nonisolated func onDisappear(
    perform action: (() -> Void)? = nil
) -> some View

Parameters

  • options.perform(() => void) | null

Return value

A view that triggers action after it disappears.

Discussion

The exact moment that SwiftUI calls this method depends on the specific view type that you apply it to, but the action closure doesn't execute until the view disappears from the interface.

See also

More in Events and lifecycle.