Setting child state to nil prints an error with Composable Architecture

Hello I hope you guys having a nice start of the week.

I have a problem with bindings.
I would like to show a cover view depending on the optional child state. And in the child state I have a text binding. But the problem is when the keyboard is visible and I tap close button (setting the optional state to nil in this case) prints out and error in the console.

This is generally considered an application logic error, and can happen for a few reasons:

• A parent reducer set child state to "nil" before this reducer ran. This reducer must run before any other reducer sets child state to "nil". This ensures that child reducers can handle their actions while their state is still available.

• An in-flight effect emitted this action when child state was "nil". While it may be perfectly reasonable to ignore this action, consider canceling the associated effect before child state becomes "nil", especially if it is a long-living effect.

• This action was sent to the store while state was "nil". Make sure that actions for this reducer can only be sent from a view store when state is non-"nil". In SwiftUI applications, use "IfLetStore".
2022-11-21 18:03:08.298698+0100 OptinalChildStateProblem[88762:12894750] [ComposableArchitecture] A binding action sent from a view store at "OptinalChildStateProblem/ContentView.swift:50" was not handled. …

  Action:
    OptionalDomain.Action.binding(.set(_, ))

To fix this, invoke "BindingReducer()" from your feature reducer's "body".

This is a sample project to demonstrate the problem.

Anybody have any idea how to fix it or should I just ignore it since it seems like a reasonable case.

The repo you linked to doesn't seem to have any TCA code in it. Have you pushed everything?

But, without looking at the code I think I know the issue. There is a long standing bug in SwiftUI where TextFields write to their bindings too often. Each character typed writes twice, when focusing/de-focusing the field writes again, and probably more situations.

For your situation, I'm guessing that when the view is dismissed, the text field writes to the binding one last time, and hence sends an action, and that action is received when the child state is nil.

This has come up in our issues/discussions a few times (see here and here), and until the SwiftUI bug is fixed the only solution is to tack on a removeDuplicates() to your binding, as discussed in those links.

Ah my mistake. I pushed the demo project.
Thank you I will check out the links.