Skip to content

Instantly share code, notes, and snippets.

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