Skip to content

Instantly share code, notes, and snippets.

@M1r1k
Created August 31, 2016 14:21
Show Gist options
  • Save M1r1k/4fdae180759d48a7aa78d7040684f887 to your computer and use it in GitHub Desktop.
Save M1r1k/4fdae180759d48a7aa78d7040684f887 to your computer and use it in GitHub Desktop.
Magic of ES6
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;
@pixelbits-mk
Copy link

pixelbits-mk commented Aug 6, 2021

Northwest Territories and Nunavut are missing from the map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment