Skip to content

self._printChanges() causes infinite recursion #3500

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

You must be logged in to vote

Hi @iharandreyev, you cannot use _printChanges in this way:

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 _printChanges() to a reducer, like at the root:

let rootStore = Store(initialState: Root.State()) {
  Root()
    ._printChanges()
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by iharandreyev
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