diff --git a/Sources/ComposableArchitecture/Core.swift b/Sources/ComposableArchitecture/Core.swift index 0c1461c74193..f853848df963 100644 --- a/Sources/ComposableArchitecture/Core.swift +++ b/Sources/ComposableArchitecture/Core.swift @@ -204,6 +204,9 @@ final class ScopedCore: Core { let base: Base let stateKeyPath: KeyPath let actionKeyPath: CaseKeyPath + #if DEBUG + let isInPerceptionTracking = _PerceptionLocals.isInPerceptionTracking + #endif init( base: Base, stateKeyPath: KeyPath, @@ -216,7 +219,13 @@ final class ScopedCore: Core { @inlinable @inline(__always) var state: State { - base.state[keyPath: stateKeyPath] + #if DEBUG + return _PerceptionLocals.$skipPerceptionChecking.withValue(isInPerceptionTracking) { + base.state[keyPath: stateKeyPath] + } + #else + return base.state[keyPath: stateKeyPath] + #endif } @inlinable @inline(__always)