davidkpiano / react-redux-form

Create forms easily in React with Redux.
https://davidkpiano.github.io/react-redux-form
MIT License
2.07k stars 251 forks source link

Adding dispatch function to arguments for Control props such as validators, asyncValidators and changeAction #770

Open bryan-foong opened 7 years ago

bryan-foong commented 7 years ago

Is there anyway we can have the dispatch function included as 1 of arguments for validators, asyncValidators and changeAction? It would be easier we can just do:

asyncValidators={{usernameExist}}

instead of:

asyncValidators={{usernameExist: (value, done) => usernameExist(value, done, dispatch) }}

I believe changeAction is coupled with redux-thunk for dispatching an action, any solution if we are using other library such as redux-saga instead of redux-thunk?

davidkpiano commented 7 years ago

What is your use-case for wanting dispatch in there?

Also, changeAction is completely agnostic to what you return from it. It accepts an action creator, or an action thunk creator, or anything else if you're using something like redux-saga or redux-observable.