Last active
March 12, 2017 17:53
-
-
Save hrishimittal/0cd3fd68f585f03f271017b88cfe1595 to your computer and use it in GitHub Desktop.
react form validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export const FormErrors = ({formErrors}) => | |
<div className='formErrors'> | |
{Object.keys(formErrors).map((fieldName, i) => { | |
if(formErrors[fieldName].length > 0){ | |
return ( | |
<p key={i}>{fieldName} {formErrors[fieldName]}</p> | |
) | |
} else { | |
return ''; | |
} | |
})} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm install -g create-react-app | |
$ create-react-app react-form-validation-demo | |
$ cd react-form-validation-demo/ | |
$ npm start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment