Invariant Violation: Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.(…)
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 312
- PR merge metrics
- No merged PRs in 30d
Description
I'm using [this](http://alt.js.org/docs/async) approach for asyncs in my application but always getting this error:
> Invariant Violation: Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.(…)
I'm async function like this:
```
if (!this.getInstance().isLoading()) {
this.getInstance().performSearch();
}
```
With setTimeout everything works perfect.
Contributor guide
Research direction
Start with the linked async documentation and the Dispatch.dispatch error, then build a minimal reproduction around the shown performSearch call with and without setTimeout. Done means the async path is understood and the reproduction no longer triggers the dispatch invariant.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100