onGeometryChange(for:, of:, action:) seems to have a similar issue as GeometryReader
#129
Unanswered
josh-arnold-1
asked this question in
Q&A
Replies: 1 comment
-
|
To add to the original report -- my observation is that even though the access is untracked and triggers the Perception checker, the code inside of the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey team, has anyone noticed that the
onGeometryChange(for:, of:, action:)modifier seems to have a similar issue when accessing perceptible state?Specifically, its totally fine to access our perceptible state inside of the
action:block — but if we try to access our perceptible state inside of the firstof:closure, we run into a runtime warning about our perception state not being tracked.myView .onGeometryChange(for: Bool.self) { _ in return myPerceptible.someValue // <-- this access is untracked } action: { _ in // do work }With the geometry reader, we can just wrap our view inside of
WithPerceptionTrackinghowever, since theof:block returns a generic value, theres no easy way to leverageWithPerceptionTrackingto ensure our access to our perceptible properties are tracked.Does anyone have thoughts on this? Is this a known limitation?
I think it can potentially be solved by just doing something like this, but I'm wondering if we have a better solution.
myView .onGeometryChange(for: ...) { geo in return geo // just pass through the geometry information } action: { geo in // access perceptible state here }Thanks!
Beta Was this translation helpful? Give feedback.
All reactions