
npm install react-validation-component!react validation component logo
React Validation Component is a utility component that solves data validation problem with the help of "native" React tool - prop-types.
Just show me the code!
``js
import React, { Component } from 'react';
import ReactValidation from 'react-validation-component';
import PropTypes from 'prop-types';
class MyComponent extends Component{
constructor(){
super();
this.state = { username: '', age: 0 };
this.myForm = {
username: PropTypes.string.isRequired
age: PropTypes.number.isRequired
};
}
onFormValidation(errors){
// this method are going to be called on every validation
}
render(){
const { username, age } = this.state;
return