add .onDelete to ForEach.๏ผwhen elements in the ForEach view are deleted
delete item from the underlying collection of data (in the action closure).
// list data from environment object// (assume `data` is the environment object)ForEach(data.creatures) { creature inCreatureRow(creature: creature)}// โญ๏ธ when elements in the ForEach view are deleted.onDelete { indexSet in/// โข SwiftUI passes a set of indices to the closure /// thatโs relative to the dynamic viewโs underlying collection of data.// โญ๏ธ delete corresponding items from the underlying collection of data data.creatures.remove(atOffsets: indexSet)}