self._printChanges() causes infinite recursion #3500
-
Hello everybody. I'm pretty sure I've messed up something with Scoping. TCA is 1.15.2 The project is attached: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @iharandreyev, you cannot use var body: some ReducerOf<Self> {
self._printChanges()
…
} That is composing a reducer into itself, and hence the infinite loop. The same thing would happen in vanilla SwiftUI if you did this: var body: some View {
self
} Instead you need to apply let rootStore = Store(initialState: Root.State()) {
Root()
._printChanges()
} |
Beta Was this translation helpful? Give feedback.
Hi @iharandreyev, you cannot use
_printChanges
in this way:That is composing a reducer into itself, and hence the infinite loop. The same thing would happen in vanilla SwiftUI if you did this:
Instead you need to apply
_printChanges()
to a reducer, like at the root: