title: SwiftUI refresh list on alert accept
body: <p>I'm having an issue with SwiftUI implementation of refreshing list items within a SwiftUI list once one has been deleted.</p>
  
  <p>The list represents a Users' friend requests, and each row is a unique instance of a view <code>FriendRequestRow()</code></p>
  
  <p>Here's an image showing what each row on the friend request list looks like <a href="https://i.stack.imgur.com/oPPDI.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/oPPDI.jpg</a></p>
  
  <p>My issue is that when the red X button is clicked and users are taken to an alert (<a href="https://i.stack.imgur.com/yAoqH.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/yAoqH.jpg</a>) and select 'Remove', it successfully removes the value from the application database, but the deleted row persists in the list until the view is re-rendered.</p>
  
  <p>Below is the code for the view holding the list, with some non-essential lines removed.</p>
  
  <pre><code>struct FriendsListView: View {
  
  @State var Friend_Request_Array : [Friend] = []
  @State var Current_Friend_Array : [Friend] = []
  
  var body: some View {
      VStack {
          HStack{
              Text("Friend Requests")
              .font(.headline)
              .padding()
              .foregroundColor(Color.white)
  
              Spacer()
          }
          .background(Color(UIColor.systemGray))
          .padding(.top, -8)
  
          // List of friend requests.
          List {
              ForEach(Friend_Request_Array) { Friend in
                  FriendRequestRow(Friend: Friend, Friend_Display_Name: "")
              }
          }
          .buttonStyle(PlainButtonStyle())
          .frame(minHeight: 0, maxHeight: 150)
  
      }.navigationBarTitle(Text("Your Friends"), displayMode: .inline)
      .navigationBarItems(trailing: Button(action: {
  
      }) {
          Image(systemName: "plus")
      })
          .onAppear{
              self.Friend_Request_Array = []
              self.Current_Friend_Array = []
              self.Load_Friends()
      }
  }
  
  func Load_Friends() {
      // Load lists full of friends.
  
      let db = Firestore.firestore()
  
      // Populates friend request array with pending friend requests.
  
      // Populates current friends array with all of the current users' friends.
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Then, here's the view for each individual list row:</p>
  
  <pre><code>struct FriendRequestRow: View {
  
  @State var Friend: Friend
  @State var Friend_Display_Name: String
  
  @State private var showingDeleteRequestAlert = false
  
  var body: some View {
      HStack{
          Image("example-avatar")
              .resizable()
              .frame(width: 40, height: 40)
              .clipShape(Circle())
  
          VStack(alignment: .leading){
              Text(Friend_Display_Name)
                  .font(.headline)
          }.padding()
  
          Spacer()
  
          Button(action: {
              // Accept request.
  
          }) {
              Image(systemName: "checkmark.circle.fill")
                  .font(.system(size: 30))
                  .foregroundColor(Color(UIColor.systemGreen))
          }
  
  
          Button(action: {
              // Deny and remove friend request. Should pop up an 'are you sure' alert.
              self.showingDeleteRequestAlert = true
          }) {
              Image(systemName: "xmark.circle.fill")
                  .font(.system(size: 30))
                  .foregroundColor(Color(UIColor.systemRed))
          }
          .alert(isPresented: $showingDeleteRequestAlert) {
          Alert(title: Text("Are you sure?"),
                message: Text("If you delete this request it will have to be resent."), primaryButton: .destructive(Text("Remove")) {
                  // Removal of request from the database
  
                  // Re-render list
                  // **THIS IS WHERE MY ISSUE IS, HOW DO I RERENDER LIST?**
  
  
              }, secondaryButton: .cancel())
          }
  
  
      }.onAppear{
          // Get Each users display name.
      }
  }
  </code></pre>
  
  <p>As seen, I populate the list using the onAppear attribute when the view is loaded from a navigation link. However, this means that when users click to 'remove' each friend request, it doesn't get reflected in the list until the view is re-rendered (click back and then click the navigation link again). Help!</p>