Skip to content

The dispatch initializer ends in an endless loop on init when dispatching any action  #1077

@rucsi

Description

@rucsi

I'm trying to use the the dispatch initializer as it is in the example with a log effect

const middleware = (dispatch) => 
  (action, payload) => {
    // Dispatch anonymous action which triggers logging effect.
    dispatch((state) => [state, log(state)]) 
    
    // Afterwards, carry on normally.
    dispatch(action, payload)
  }

app({
  // ...
  dispatch: middleware
})

but it ends in an endless loop. no matter what my log effect does. even if I just do dispatch(state => state) it gets in the loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions