简体   繁体   中英

redux-form SubmissionError not updating error state

I'm having trouble setting up a simple form that shows validation only on submission with redux-forms SubmissionError (similar to what's shown in the official RF docs example ).

The errors prop is always being undefined for the given Field component, even when the submit function only throws SubmissionError (as seen below).

I was initially on v6.8.0 , but updated to v7.3.0 and noticed the same behavior:

class Login extends React.Component {

  ...

  onEmailSubmit = values => {
    return Promise.resolve(true).then(() => {
      throw new SubmissionError({
        email: 'Invalid email address'
      })
    })
  }

  render () {
    const { handleSubmit } = this.props

    return (
      <form onSubmit={handleSubmit(this.onEmailSubmit)}>
        <Field
          name='email'
          type='text'
          component={Input}
          label='Email'
          placeholder='Please enter your email address'
        />
        <Button type='submit'>
          Next
        </Button>
      </form>
    )
  }
}

In the store, there's no indication of an error state upon submit:

图片

Any insight would be much appreciated!

有点晚了,但尝试使用 await 执行此操作并在其下方抛出 SubmissionError

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM