---
title: "init(initialValue:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/lazystate/init(initialvalue:)"
---

# init(initialValue:)

Creates a state property that stores an initial wrapped value.

## Declaration

```swift
init(initialValue thunk: @escaping () -> Value)
```

## Discussion

Discussion You don’t call this initializer directly. Instead, SwiftUI calls it for you when you declare a property with the @State attribute and provide an initial value: struct MyView: View {     @State private var isPlaying: Bool = false

// ... } SwiftUI initializes the state’s storage only once for each container instance that you declare. In the above code, SwiftUI creates isPlaying only the first time it initializes a particular instance of MyView. On the other hand, each instance of MyView creates a distinct instance of the state. For example, each of the views in the following VStack has its own isPlaying value: var body: some View {     VStack {         MyView()         MyView()     } }

## See Also

### Creating a lazy state

- [init()](swiftui/lazystate/init().md)
