Skip to content

Bug on 3.0.0 #303

Closed
Closed
@arnauddorgans

Description

@arnauddorgans

Since 3.0.0 WebImage is not able to update its URL

on v2.2.7

Screen.Recording.2024-03-16.at.03.12.07.mov

on v3.0.0

Screen.Recording.2024-03-16.at.03.16.16.mov

Full code

struct ContentView: View {
    @State var isOn = false

    var url: URL? {
        if isOn {
            .init(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Google_%22G%22_logo.svg/1024px-Google_%22G%22_logo.svg.png")
        } else {
            nil
        }
    }

    var body: some View {
        VStack {
            WebImage(url: url)
                .resizable()
                .scaledToFit()
                .frame(width: 50, height: 50)
            Button("Toggle") {
                isOn.toggle()
            }
        }
    }
}

I found a workaround by setting .id(url) but I don't think this is optimized

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions