Skip to content

Runtime warning when dismissing sheet with TextField focused #3503

Answered by mbrandonw
seanmrich asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @seanmrich, is there a reason you are constructing a binding from scratch instead of using the tools of the library? Like this:

text: $store.value

If you do that the runtime warning is suppressed.

The reason the runtime warning is happening is because as the child view is dismissed, SwiftUI writes to the text field binding (for some reason). That causes an action to be sent, and by that point the state has been nil'd out, and hence the warning. Really it's a SwiftUI bug, but we've long lost hope of it ever being fixed.

And so we have special logic in the library for suppressing the warning under certain circumstances. If you use the binding helpers you will get access to that functiona…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@seanmrich
Comment options

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