Skip to content

Perception warning with Custom Bindings #32

Answered by mbrandonw
wes-nz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @wes-nz, unfortunately there's nothing we can do (as far as we know) to detect when bindings are accessed in view bodies vs out of view bodies. Since TCA can control the creation of bindings we perform extra work in them to disable perception checks.

If you really do want to create your own ad hoc bindings, then you can wrap state access inside the get with _withoutPerceptionChecking to disable perception checking for a lexical scope.

However, I would highly recommend against creating ad hoc bindings like this. Not only does it run afoul of things like perception checking, but it can also breaking SwiftUI animations in subtle ways. For whatever reason, deriving bindings via dynamic mem…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@wes-nz
Comment options

@zhuscat
Comment options

Answer selected by wes-nz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants