     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()
     }
 }
 


extension Window {
    final class ViewController: UIViewController {
        private var hostingWindow: UIHostingWindow<RootView>?
        fileprivate typealias RootView = Window.RootView<Content>
        var isPresented: Binding<Bool>
        var style: WindowStyle
        var rootView: RootView {
            didSet {
                hostingWindow?.rootView = rootView
            }
        }

        init(isPresented: Binding<Bool>, style: WindowStyle, rootView: RootView) {
            self.isPresented = isPresented
            self.style = style
            self.rootView = rootView
            super.init(nibName: nil, bundle: nil)
        }


        }

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

        func update() {
            if isPresented.wrappedValue {
                hostingWindow.show(isKey: style.isKey)
            } else {
                hostingWindow.hide()
            }
        }
    }
