Explore Library
iOS Developer EssentialsArchitecture Patterns (MVC, MVVM, Clean)

32 items

Code QuizAdvanced

Reusable Component Ignores Its Input

A SwiftUI component hardcodes its data instead of receiving it, breaking reuse and separation of concerns.

Codeswift
struct AvatarBadge: View {
    let username: String

    var body: some View {
        HStack {
            Image(systemName: "person.circle")
            Text("Guest")
        }
    }
}

struct ProfileHeader: View {
    var body: some View {
        AvatarBadge(username: "alice")
    }
}

What is the bug that breaks this component's reusability?