transformEnvironment

Transforms the environment value of the specified key path with the given function.

View ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+transformEnvironment(_:transform:) in SwiftUI

Declaration

React
compose().transformEnvironment<K extends keyof SwiftUI.EnvironmentValuesWritable>(
  keyPath: K,
  options: {
    transform: SwiftUI.EnvironmentValuesWritable[K];
  }
)
Swift
nonisolated func transformEnvironment<V>(
    _ keyPath: WritableKeyPath<EnvironmentValues, V>,
    transform: @escaping (inout V) -> Void
) -> some View

Parameters

See also

More in State and environment.