Skip to content

Instantly share code, notes, and snippets.

@iamkevingreen
Created November 17, 2016 01:36
Show Gist options
  • Save iamkevingreen/edb960116daa43379cf1ce3839a76f84 to your computer and use it in GitHub Desktop.
Save iamkevingreen/edb960116daa43379cf1ce3839a76f84 to your computer and use it in GitHub Desktop.
import React from 'react'
import Formsy from 'formsy-react'
const Input = React.createClass({
mixins: [Formsy.Mixin],
changeValue(event) {
this.setValue(event.currentTarget.value)
},
render() {
const className = this.showRequired() ? 'required' : this.showError() ? 'error' : null;
const errorMessage = this.getErrorMessage();
return (
<div className={className}>
<label>{this.props.label}
<input type={this.props.type || 'text'} name={this.props.name} onChange={this.changeValue} value={this.getValue()} />
</label>
</div>
)
}
})
export default Input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment