# How does SwiftUI find @State properties in views?

**URL:** <https://forums.swift.org/t/how-does-swiftui-find-state-properties-in-views/79984>\
**Category:** Using Swift\
**Tags:** off-topic, swiftui\
**Created:** [May 19, 2025, 2:42pm UTC](https://forums.swift.org/t/how-does-swiftui-find-state-properties-in-views/79984 "2025-05-19T14:42:23Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mayoff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/mayoff/32/613_2.png) [@mayoff](https://forums.swift.org/u/mayoff)\
**Post date:** [May 19, 2025, 6:11pm UTC](https://forums.swift.org/t/how-does-swiftui-find-state-properties-in-views/79984/3 "2025-05-19T18:11:09Z")

</div>

I believe SwiftUI doesn't use `Mirror`, but instead uses type metadata directly to learn the layout of each `View`-conforming type on demand.

By looking at the metadata directly, SwiftUI gains some efficiency advantages over `Mirror`. First, SwiftUI can cache layout information in whatever format it finds most convenient. Second, SwiftUI can poke around in `View` values without necessarily going through `Any` conversions (which `Mirror` always performs) and without creating [`AnyCollection`](https://developer.apple.com/documentation/swift/mirror/children-swift.typealias) instances and corresponding iterators.

I think SwiftUI also uses type metadata to decompose instances of [`TupleView`](https://developer.apple.com/documentation/swiftui/tupleview#).

I'm not sure if [the type metadata documentation](https://github.com/swiftlang/swift/blob/main/docs/ABI/TypeMetadata.rst) is currently complete or up to date. I've had trouble in the past with it being neither. But the SwiftUI engineers probably got some help from the Swift language engineers. There are also some open source packages for examining Swift metadata, like [Azoy/Echo](https://github.com/Azoy/Echo), that I have found very educational.

[Echo's primary author](https://github.com/Azoy) now works for Apple on the Swift standard library.

---

_[View the full topic](https://forums.swift.org/t/how-does-swiftui-find-state-properties-in-views/79984)._
