How to create a simple Binding for previews

You can use .constant(VALUE) in your Previews, no need to create a @State.

/// A value and a means to mutate it.
@propertyWrapper public struct Binding<Value> {

    /// Creates a binding with an immutable `value`.
    public static func constant(_ value: Value) -> Binding<Value>
}

e.g.

TestView(someProperty: .constant(5.0))

Leave a Comment