An ifLet received a child action when child state was nil #1663
Unanswered
JaapWijnen
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi @JaapWijnen, this is unfortunately a known, long-standing bug in SwiftUI. Text field bindings fire twice for some reason. We've filed a feedback about it, and there are been a few discussion about it in the past (e.g. here and here). There's a workaround to use a kind of I'm not sure about the second one. I don't have enough time to dive into the code right now. |
Beta Was this translation helpful? Give feedback.
2 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.
-
Hi! I'm having some trouble properly implementing some navigation. I've rebuilt the Inventory app from swiftui-navigation using TCA.
When performing some actions in my app I get the An ifLet received a child action when child state was nil runtime error. I think it's caused by a binding reemitting an action before being deallocated.
When I press the add button to add a new item to the inventory enter a name and then press cancel the following happens:
.addButtonTapped
fires and sets the route so that the add item sheet is opened.setName
fires and changes the name of the item.cancelButtonTapped
action is fired (this sets the route to nil).setName fires
(again?) with the same name as set by the first time it was fired. This causes the error since the route is already set to nil by the previous action. I'm not sure why the setName binding fires again and/or how to prevent it!I have a similar problem for a .forEach scoping where the following happens when I have an item in the inventory and press the delete button and then press Delete to confirm the deletion in the alert that's presented:
.deleteButtonTapped
fires and sets the route so that the delete alert is presented.deleteConfirmationButtonTapped
fires after the confirmation is tapped. this removes the item from the inventory collection and therefore the route is deleted since it's contained in theItemRow.State
that is deleted from inventory.setRoute
fires since the alert will disappear, this triggers the runtime error "forEach" received an action for a missing element. since the Element no longer exists in the array ofItemRow
sHelp would be really appreciated!
Any tips? My code can be found here: https://github.com/JaapWijnen/swift-composable-architecture/tree/inventory-example
Beta Was this translation helpful? Give feedback.
All reactions