title: How to implement WKUIDelegate into SwiftUI WKWebView?
body: <p>I'm creating a web app on Xcode v11 and having a trouble implementing WKUIDelegate to display Javascript alert and confirm properly on the web app.</p>
  
  <p>I got a very simple webview app with below code on ContentView.swift but not sure how to implement <code>WKUIDelegate</code> properly with this code.</p>
  
  <pre><code>import SwiftUI
  import WebKit
  
  struct Webview : UIViewRepresentable {
      let request: URLRequest
      var webview: WKWebView?
  
      init(web: WKWebView?, req: URLRequest) {
          self.webview = WKWebView()
          self.request = req
      }
  
      func makeUIView(context: Context) -&gt; WKWebView  {
          return webview!
      }
  
      func updateUIView(_ uiView: WKWebView, context: Context) {
          uiView.load(request)
      }
  
      func goBack(){
          webview?.goBack()
      }
  
      func goForward(){
          webview?.goForward()
      }
  
      func reload(){
          webview?.reload()
      }
  }
  
  struct ContentView: View {
  
      let webview = Webview(web: nil, req: URLRequest(url: URL(string: "https://google.com")!))
  
      var body: some View {
          VStack {
              webview
              HStack() {
                  Button(action: {
                      self.webview.goBack()
                  }){
                      Image(systemName: "chevron.left")
                  }.padding(32)
  
                  Button(action: {
                      self.webview.reload()
                  }){
                      Image(systemName: "arrow.clockwise")
                  }.padding(32)
  
                  Button(action: {
                      self.webview.goForward()
                  }){
                      Image(systemName: "chevron.right")
                  }.padding(32)
              }.frame(height: 32)
          }
      }
  }
  
  struct ContentView_Previews: PreviewProvider {
      static var previews: some View {
          ContentView()
      }
  }
  
  </code></pre>
  
  <p>What is the best way to implement <code>WKUIDelegate</code> into this code? So, it will display Javascript Alert and Confirm properly.</p>