# Feature flag evaluation in leaf views

**URL:** <https://forums.swift.org/t/feature-flag-evaluation-in-leaf-views/65546>\
**Category:** Swift Composable Architecture\
**Created:** [June 13, 2023, 1:54pm UTC](https://forums.swift.org/t/feature-flag-evaluation-in-leaf-views/65546 "2023-06-13T13:54:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dk-jlew](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dk-jlew/32/29486_2.png) [@dk-jlew](https://forums.swift.org/u/dk-jlew)\
**Post date:** [June 13, 2023, 1:54pm UTC](https://forums.swift.org/t/feature-flag-evaluation-in-leaf-views/65546/1 "2023-06-13T13:54:04Z")

</div>

Hi there, wondering if anyone has a nice pattern for the following kind of situation:  
We have a UI component which is reusable across several features, and whose state is buried several layers deep inside the controlling feature's state. The component's behavior depends on a feature flag. Feature flags come from an external system via a @Dependency, which is injected at the higher feature level. We want to avoid every high-level feature needing to be aware of the flag specifics which control this shared component's behavior Since the flag controls (in this case) a show/no-show decision within SwiftUI, we could arrange for SwiftUI's @Environment to be aware of this and not have to plumb the actual boolean value down through several layers of nested state. But this seems counter to TCA best-practices.

Any thoughts?  
Thanks!
