goatslacker / goatslacker/alt

can not call DataSource function during an action

Open
#720 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.4k
Forks
312
PR merge metrics
No merged PRs in 30d

Description

During an action if we want call another action in turn, we can use xxActions.yy.defer()
But if During an action I want to call DataSource function, it will give error "cannot dispatch during an action"

How can I call DataSource function during an action?

The context is
I have a submit button, it should submit data by calling DataSource function, but before submit I wanna validate the data. so when click button, I send an action set the submitted flag and validate all data, if no error, I will call api to submit the data, if has error, won't call submit.

But I got error, Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.