Skip to content

The new IDView implementation will not trigger update when ID changes #569

@Kyle-Ye

Description

@Kyle-Ye

Since makeImplicitRoot is supported via the recent multiView / dynamicView PR, I'm trying to unlock the new IDView implementation:

@available(OpenSwiftUI_v1_0, *)
extension IDView {
    @usableFromInline
    package static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
        if _SemanticFeature_v2.isEnabled {
            return makeImplicitRoot(view: view, inputs: inputs)
        } else {
            let id = view.value[offset: { .of(&$0.id) }]
            let phase = IDPhase(id: id, phase: inputs.viewPhase, lastID: nil, delta: 0)
            var inputs = inputs
            inputs.viewPhase = Attribute(phase)
            return Content.makeDebuggableView(view: view[offset: { .of(&$0.content)}], inputs: inputs)
        }
    }
}

But if it is enabled, no update will happen even we change the ID.

struct ContentView: View {
    @State private var showRed = false

    var body: some View {
        Color(platformColor: showRed ? .red : .blue)
            .onAppear {
                DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                    showRed.toggle()
                }
            }
            .id(showRed)
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions