jurassix / react-validation-mixin

Simple validation mixin (HoC) for React.
MIT License
282 stars 38 forks source link

Validate in componentDidMount() -> Uncaught Invariant Violation #70

Closed rahulthewall closed 8 years ago

rahulthewall commented 8 years ago

I want to validate the forms as soon as it is loaded (yes, I know it will display all the error messages on relevant fields on form load, but this is exactly what I want).

I called this.props.validate() in componentDidMount() and I got the following error:

Uncaught Invariant Violation: Data was not provided to the Validator. Implement "getValidatorData" to return data.

However, the function getValidatorData() is implemented.

getValidatorData() {
    return this.state.contact.person;
  }

Validation works as expected while editing the form (so it seems that everything else is properly implemented).

How do I validate when the component gets mounted?

rahulthewall commented 8 years ago

Never mind, I have realised that showing the error messages on render is stupid.