'Pulling down the Drop Down Notification Sheet Resets/Reloads the Swift WKWebView Content back to the top

Demo Here How do i stop this reset and let the screen stay as it is even if i pull down the notifications screen?

Below code is what i use to display the html data thats coming from an API.i just pass the URL to this struct and this struct will take care of displaying the data.

struct URLView : UIViewRepresentable
{
    
    let request: URLRequest
    
    func makeUIView(context: Context) -> WKWebView { return WKWebView()
        
    }
    func updateUIView(_ uiView: WKWebView, context: Context) { uiView.load(request)
    
}
    
}


Solution 1:[1]

You are loading request each time SwiftUI updates view. This is not a good solution, coz there are a lot of cases that causes updates (size, orientation changes, etc.) Move your request loading to makeUIView

func makeUIView(context: Context) -> WKWebView {
    let webView = WKWebView()
    webView.load(request)
    return webView
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 severehed