Created
August 31, 2016 14:21
-
-
Save M1r1k/4fdae180759d48a7aa78d7040684f887 to your computer and use it in GitHub Desktop.
Magic of ES6
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, { PropTypes } from 'react'; | |
import FormInput from './FormInput'; | |
const TextInput = (props) => { | |
let {onChange, validate, errorText, name, ...properties} = props; | |
const handleChange = (e) => onChange(name, e.target.value); | |
const handleValidation = (e) => validate && validate({[name]: e.target.value}); | |
return ( | |
<FormInput errorText={props.errorText}> | |
<input name={name} {...properties} /> | |
</FormInput> | |
); | |
}; | |
TextInput.defaultProps = { | |
type: 'text', | |
value: '' | |
}; | |
TextInput.propTypes = { | |
type: PropTypes.string, | |
name: PropTypes.string.isRequired, | |
onChange: PropTypes.func.isRequired, | |
validate: PropTypes.func, | |
errorText: PropTypes.string, | |
value: PropTypes.oneOfType([ | |
PropTypes.string, | |
PropTypes.number | |
]) | |
}; | |
export default TextInput; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Northwest Territories and Nunavut are missing from the map.