         change: [NSKeyValueChangeKey: Any]?,
         context _: UnsafeMutableRawPointer?
     ) {
-        guard let change = change, _setupComplete, !_suppressUpdates else {
+        guard _setupComplete, !_suppressUpdates, let new = change?[.newKey] else {
             return
         }
-        if let new = change[.newKey] as? CGRect {
-            if !new.size.isNearlyEqual(to: frame.size) {
+        switch new {
+        case let rect as CGRect:
+            if !rect.size.isNearlyEqual(to: frame.size) {
                 var root = self
                 while let parent = root.parent {
                     root = parent

        guard _suppressUpdates == false, let _view = _view else { return }
        defer { _suppressUpdates = false }
        _suppressUpdates = true
        if _view.translatesAutoresizingMaskIntoConstraints {
            let transform = _view.layer.transform
            _view.layer.transform = CATransform3DIdentity
            _view.frame = frame
            _view.layer.transform = transform
        } else if let _widthConstraint = _widthConstraint, let _heightConstraint = _heightConstraint {
            setUpConstraints()
            _widthConstraint.constant = frame.width
            _widthConstraint.isActive = true
            _heightConstraint.constant = frame.height
            _heightConstraint.isActive = true
        }
        for child in children {
            try LayoutError.wrap(child.updateFrame, for: self)

                    root.update()
                }
            }
        case let insets as UIEdgeInsets:
            if _view?.window != nil, !insets.isNearlyEqual(to: _previousSafeAreaInsets) {
                // If not yet mounted, safe area insets can't be valid
                update()
            }
            _previousSafeAreaInsets = insets
        default:
            preconditionFailure()
        }
    }

