AppStorage
A property wrapper type that reflects a value from UserDefaults and invalidates a view on a change in value in that user default.
Declaration
import { AppStorage } from 'swiftui-react-native';@frozen @propertyWrapper struct AppStorage<Value>Initializers
8 SwiftUI initializers back <AppStorage>. The props you pass pick one.
<AppStorage
wrappedValue: string
swiftKey: string
store?: string | null
>
children: (value: string, setValue: (value: string) => Promise<void>) => ReactNode
</AppStorage>init(
wrappedValue: Value,
_ key: String,
store: UserDefaults? = nil
)
where Value == URLchildren*(value: string, setValue: (value: string) => Promise<void>) => ReactNodeRenders the value, again whenever it changes.
wrappedValue*stringThe default value if a url value is not specified for the given key.
swiftKey*stringThe key to read and write the value to in the user defaults store.
Swift
key: Stringstorestring | nullThe user defaults store to read and write to. A value of
nilwill use the user default store from the environment.Default
`nil`
Also takes the common view props: modifiers, style and testID.
See also
More in State and environment.