/// A property wrapper for reactive state owned by a ``View``. /// /// Mutations fire targeted updates — only widgets that read this state /// (via ``Binding`` or a tracked closure) are affected. The backing /// ``StateBox`` is a reference type, so struct copies share the same /// storage (``nonmutating set`` on a `let` wrapper). /// /// ```swift /// struct Counter: View { /// @State private var count = 0 /// var body: some View { /// HStack { /// Button("-") { count -= 1 } /// Label { "\(count)" } /// Button("+") { count += 1 } /// } /// } /// } /// ``` @propertyWrapper @MainActor public struct State { private let box: StateBox public init(wrappedValue: Value) { box = StateBox(wrappedValue) } /// The current value. Reads track dependencies; writes notify. public var wrappedValue: Value { get { box.get() } nonmutating set { box.set(newValue) } } /// A ``Binding`` to this state, for passing to child views. public var projectedValue: Binding { Binding(box) } }