Skip to content
RED SAG Skills
hardStudy question · answer published in iOS interview questions, so no pointsswiftswiftuistate

@State ignores the new value

A view initialises @State from a parameter. The parent later passes a different start value, but the view keeps showing the old one. Why?

struct Stepper: View {
    @State private var count: Int
    init(start: Int) { _count = State(initialValue: start) }
    var body: some View { Text("\(count)") }
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions