Skip to content

Images not loading via observable objects (@State in my case) #229

Closed
@shanezzar

Description

@shanezzar
struct UserListView: View {
  var user: CompactMatch

  @State var imageURL: URL = nil
  
  var body: some View {
    HStack {
        WebImage(url: imageURL)
            .resizable()
            .placeholder {
                Image("placeholder-blank")
                    .resizable()
            }
            .indicator(.activity)
            .transition(.fade(duration: 0.5))
            .aspectRatio(contentMode: .fill)
            .frame(width: 72, height: 72, alignment: .center)
            .clipped()
            .cornerRadius(24)
    }
    .task { // .onAppear
        switch user {
        case .compact(let user):
            imageURL = user.imageURL
        case .match(let user):
            image = user.imageURL
        }
    }
  }
}

It's after the update 2.1.0. Can you please look into it, .onFailure description prints imageURL is nil whereas it is working with the older releases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions