---
title: "onDelete(perform:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/dynamicviewcontent/ondelete(perform:)"
---

# onDelete(perform:)

Sets the deletion action for the dynamic view. You must delete the corresponding item within action, as it will be called after the row has already been removed from the List.

## Declaration

```swift
nonisolated func onDelete(perform action: Optional<(IndexSet) -> Void>) -> some DynamicViewContent

```

## Parameters

- `action`: The action that you want SwiftUI to perform when elements in the view are deleted. SwiftUI passes a set of indices to the closure that’s relative to the dynamic view’s underlying collection of data.

## Mentioned in

Picking container views for your content

## Return Value

Return Value A view that calls action when elements are deleted from the original view.

## See Also

### Responding to updates

- [onInsert(of:perform:)](swiftui/dynamicviewcontent/oninsert(of:perform:).md)
- [onMove(perform:)](swiftui/dynamicviewcontent/onmove(perform:).md)
- [dropDestination(for:action:)](swiftui/dynamicviewcontent/dropdestination(for:action:).md)
