question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

5.3.3: Clear submit errors on field change?

See original GitHub issue

Thanks for this great library!

Is there a way to clear the form-level submit error when field data changes?

The submit error no longer applies once the user has changed their entry, so I want to stop showing it to the user until they’ve tried submitting again. I haven’t been able to find out how to do that.

Note, this code might be slightly off since I edited it for posting here, but any fix that would work for this would work for my site code.

Sample container code:

function mapDispatchToProps(dispatch, ownProps)
{
  return {
    mySubmitHandler: (values) =>{      
      return dispatch(asyncSubmit(values.name, values.email))
      .catch(err=>{
        return Promise.reject({_error: err.message});
      });
    }
  };
}

Sample component code:

const RegistrationDialog = (props) => {
  const { fields: {name, email},
    handleSubmit,
    mySubmitHandler,
    submitting,
    error  } = props;

return (
<form onSubmit={ handleSubmit((values)=>{return mySubmitHandler(values)}) }>
    <input type="text" {...name}/>
    <input type="text" {...email}/>
    { error && <ErrorMessageView message={ error }/> }
    <button>Submit</button>
</form>
);

Alternatively, is there a property to check whether any field data has changed since the submit error happened, that I can use to hide the error message component?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
Didericiscommented, Nov 6, 2017

In 7.1.2 there’s a clearSubmitErrors action creator that you can call in the onChange handler for your form:

export default reduxForm({ 
  form: 'login',
  onChange: (values, dispatch, props) => {
    if (props.error) dispatch(clearSubmitErrors('login'));
  }
})
1reaction
The-Code-Monkeycommented, May 18, 2018

@Didericis that doesn’t seem to do anything for me as my component i have rendered under a props.submitFailed condition doesnt disappear

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redux-form v5: How to clear/hide submit error after field edited
redux-form.com/5.3.3/#/api/props) However, I'm not seeing the submit error cleared when changing a field value. Using 5.3.3. Is it possible that that behavior ...
Read more >
5.3.3. Error Code Recovery - Intel
Possible error recovery steps: For QSPI operation: Send command with a valid chip select. Send command with a valid QSPI flash address. For...
Read more >
useForm - ClearErrors - React Hook Form
This function can manually clear errors in the form. Props. Type, Description, Example. undefined, Remove all errors. clearErrors().
Read more >
HTML 5.2: 4.10. Forms - W3C
A form is a component of a Web page that has form controls, such as text fields, buttons, checkboxes, range controls, or color...
Read more >
Validation - Laravel - The PHP Framework For Web Artisans
In addition, all of the validation errors and request input will ... an error message that is located in your application's lang/en/validation.php file....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found