Skip to content

Instantly share code, notes, and snippets.

@grantglidewell
Created August 1, 2018 16:42
Show Gist options
  • Save grantglidewell/b5a452420c1ddd26c0e9d29670ec2bf0 to your computer and use it in GitHub Desktop.
Save grantglidewell/b5a452420c1ddd26c0e9d29670ec2bf0 to your computer and use it in GitHub Desktop.
export class NumberFieldType extends Component {
constructor(props) {
super(props);
this.state = {
numberInput: ""
};
}
render() {
const { numberInput } = this.state;
return (
<article
className={`${styles.NumberFieldType} ${
numberInput.length > this.props.charCount ? styles.Error : ""
}`}
>
<div className={styles.NumberFieldTypeLabel}>
<label>{this.props.label}</label>
<span>
{numberInput.length}/{this.props.charCount}
</span>
</div>
<Input type="number" onChange={this.onChange} value={numberInput} />
</article>
);
}
onChange = evt => {
this.setState({
numberInput: evt.target.value
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment