Redux-form 6.0.0 access error outside Field component

前端 未结 2 1622
悲哀的现实
悲哀的现实 2021-01-06 17:27

In Redux-form v5 I was able to access to the \"inline\" errors (async validation) from anywhere in the decorated form, like so:

const fields = [
  \'email\'
         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-06 17:37

    The solution I found is to use the error prop (http://redux-form.com/6.0.0-rc.4/docs/api/Props.md/#-error-any-). From my asyncValidate function I fill the returned error._error object with my fields errors. I can then access it from the decorated form using const { error } = this.props.

    If anyone has a better solution...

    Edit: don't do this. Use the valid answer (Fields component).

提交回复
热议问题