title: SwiftUI load data from Firebase to TextView
body: <p>I have a Swift5 project but i decided that it would be easier to build only one of it's screen with SwiftUI.<br><br>
  The problem is that i don't know anything about SwiftUI so i am sorry if my question is stupid lol.<br>
  There is a TextView on the screen and i would like to load the text data from firebase.<br>
  My problem is that i can't use the loaded data in the TextView.</p>
  
  <p>Can someone help me how i can use the function's variable in my VStack ( if its even possible )?<br>
  I tried putting the function in the VStack but it gave me some error.</p>
  
  <p>Here is my code:</p>
  
  <pre><code> var body: some View {
          List {
              VStack {
                  Text("Just some dummy data, this is not important.")
                  // i want the "text" variable from loadData() to be in this Text                
              }
          }.onAppear {
              func loadData() {
                  guard let userdef = userdefStr(forKey: "didSelect") else { return }
  
                  self.db.collection("news").whereField("title", isEqualTo: userdef)
                      .getDocuments() { (querySnapshot, err) in
                          if let err = err {
                              print("Error getting documents: \(err)")
                          } else {
                              for document in querySnapshot!.documents {
  
                                 let text = document.data()["text"] as? String ?? ""
                                  // this variable should be in the VStack's Text
                                  print("text: \(text)")
                                  Text(text)
                              }
                          }
                  }
              }
              // i think this is how i can call the loadData function,maybe i am wrong
              loadData()
          }
  }
  </code></pre>