NamespaceReader is used to create and manage a geometry animation namespace (Namespace).
This namespace is the foundational requirement for enabling:
matchedGeometryEffect (component-level geometry animation)matchedTransitionSource (page-level navigation transition)navigationTransition (such as zoom transitions)You can think of NamespaceReader as:
A “geometry animation coordinate provider” that defines which views belong to the same animation scope.
NamespaceReader is not a visual UI component. It is a namespace generator whose responsibilities are:
NamespaceIDIn Scripting, this corresponds conceptually to SwiftUI’s:
@NamespaceNamespace.IDExplanation:
NamespaceReader accepts a function as its childnamespacenamespace is the unique animation scope for all child viewsThe real purpose of a namespace is to:
Without using the same namespace:
id| Condition | Geometry Matching Occurs |
|---|---|
Same id + Same namespace |
Yes |
Same id + Different namespace |
No |
Different id + Same namespace |
No |
Different id + Different namespace |
No |
Conclusion:
Both
idandnamespacemust match exactly for geometry animation to be established.
matchedGeometryEffect relies on namespace to establish cross-view geometry mapping
NamespaceReader is a mandatory prerequisite for matchedGeometryEffect
Without NamespaceReader:
matchedGeometryEffect cannot functionPage-level navigation transitions also depend on namespace to pair:
NamespaceReader is used to:
In this example:
NamespaceReader provides the animation coordinate system
Both Circle views share:
idnamespaceTherefore, they are geometrically linked
This structure demonstrates:
namespace is created by NamespaceReader
The same namespace is used by:
This enables full page-level shared-geometry transitions
Every time NamespaceReader is created:
The namespace:
A namespace is valid only inside the render function of its NamespaceReader
It is not shared automatically across component hierarchies
If cross-component sharing is required:
Check the following:
NamespaceReader actually present?namespace correctly received and passed?Common cause:
NamespaceReader is being conditionally rendered and destroyed repeatedlyRecommendation:
NamespaceReader in a stable parent nodeif or ternary conditionsSymptoms:
id appears to be correctLikely cause:
id values are the sameUse one NamespaceReader per independent animation region
Do not create a separate NamespaceReader for every individual view
For page-level transitions:
NamespaceReader near the page rootFor component-level animations:
NamespaceReader around the logical animation groupInside the same namespace:
id for unrelated viewsAppropriate scenarios for using NamespaceReader:
Scenarios where NamespaceReader is not required: