@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)") }
}Discussion 0
Join free to post in the discussion.
Related questions
- Safely unwrapping a Swift optionalMobile App Developer
- StatelessWidget or StatefulWidgetMobile App Developer
- Swift struct assignment copiesMobile App Developer
- Swift class shared referenceMobile App Developer
- Layering views in SwiftUIMobile App Developer
- Decoding JSON with extra keysMobile App Developer
- Making a composable reusableMobile App Developer
- Counter jumps back to zeroMobile App Developer