Q:

Cannot convert value of type '()' to expected argument type '(() -> Void)?'

I encountered such a problem, does anyone have any ideas how to solve it?
Xcode 11.2, SwiftUI
.onAppear(perform: self.sessionChat.loadMsgInChatRoom(chatRoom: chatRoom)) //then an error

func loadMsgInChatRoom(chatRoom: String) {
        let db = Firestore.firestore()
        db.collection("chatRoom").document(chatRoom).collection("msg")
            .addSnapshotListener { (querySnapshot, err) in
            if err != nil {
                print((err?.localizedDescription)!)
                return
            }
            for i in querySnapshot!.documentChanges {
                if i.type == .added {
                    let user = i.document.get("user") as! String
                    let msg = i.document.get("msg") as! String
                    let idUser = i.document.get("idUser") as! String
                    let dateMsg = i.document.get("dateMsg") as! String
                    let id = i.document.documentID

                    self.msgs.append(dataMessges(id: id, user: user, msg: msg, idUser: idUser, dateMsg: dateMsg))
                }
            }
        }
    }

A:

.onAppear takes a closure, so I think curly brackets are needed 
.onAppear(perform: { self.sessionChat.loadMsgInChatRoom(chatRoom: chatRoom) } )

or the simpler way :
.onAppear { 
     self.sessionChat.loadMsgInChatRoom(chatRoom: chatRoom)
} 

