Daily iOS
SwiftUIPayPalinterview report

Finding SwiftUI defects

This is a SwiftUI live coding review. Find as many defects as you can in the feed screen code below, and for each one say why it's a problem and how you'd fix it.

struct FeedView: View {
    @ObservedObject var vm = FeedViewModel()
    @State var items: [Post] = []
    var body: some View {
        List {
            ForEach(0..<items.count) { i in
                PostRow(post: items[i])
                    .onAppear { if i == items.count - 1 { Task { await vm.loadMore() } } }
            }
        }
        .onAppear { Task { items = await vm.fetch() } }
    }
}

Submit