     func updateUIViewController(_ viewController: ViewController, context: Context) {
         viewController.isPresented = isPresented
         viewController.style = style
-        viewController.rootView.context = context
-        viewController.update()
+        viewController.hostingWindow.rootView.context = context
 
         // Fixes an issue where animations are broken.
         DispatchQueue.main.async {
-            viewController.rootView.content = content
-        }
+            viewController.hostingWindow.rootView.content = content
+        }
+
+        viewController.update()
     }
 }
 

        }

        override func didMove(toParent parent: UIViewController?) {
            super.didMove(toParent: parent)
            update()
        }

        func update() {
            if isPresented.wrappedValue {
                if hostingWindow == nil {
                    hostingWindow = UIHostingWindow(rootView: rootView)
                    hostingWindow?.windowLevel = style.level
                    hostingWindow?.windowLabel = style.label
                }

                hostingWindow?.show(isKey: style.isKey)
            } else {
                hostingWindow?.hide()
                hostingWindow = nil
            }
        }
    }


extension Window {
    final class ViewController: UIViewController {
        var hostingWindow: UIHostingWindow<RootView<Content>>
        var isPresented: Binding<Bool>
        var style: WindowStyle

        init(isPresented: Binding<Bool>, style: WindowStyle, rootView: RootView<Content>) {
            self.isPresented = isPresented
            self.style = style

            hostingWindow = UIHostingWindow(rootView: rootView).apply {
                $0.windowLevel = style.level
                $0.windowLabel = style.label
            }

            super.init(nibName: nil, bundle: nil)
        }

