Runtime warn when stack integration is missing from store's reducer (#3048)

* Runtime warn when reducer is missing stack integration

If SwiftUI writes to a binding and the state is invalid (it is not
inserting or removing elements from the stack), then the most likely
cause is a missing `forEach` in the reducer (or a missing integration in
some parent reducer).

This commit adds a runtime warning to detect this issue.

* wip
This commit is contained in:
Stephen Celis
2024-05-06 12:18:36 -07:00
committed by GitHub
parent 096c5546ac
commit c76914ee09
4 changed files with 83 additions and 8 deletions

View File

@@ -785,7 +785,7 @@ extension WithViewStore where ViewState: Equatable, Content: View {
customDump(self.value, to: &value, maxDepth: 0)
runtimeWarn(
"""
A binding action sent from a view store \
A binding action sent from a store \
\(self.context == .bindingState ? "for binding state defined " : "")at \
"\(self.fileID):\(self.line)" was not handled. …