Skip to content

Instantly share code, notes, and snippets.

@stelmakh
Created December 30, 2018 09:22
Show Gist options
  • Select an option

  • Save stelmakh/c284384044ee348bc7a7bdef43052544 to your computer and use it in GitHub Desktop.

Select an option

Save stelmakh/c284384044ee348bc7a7bdef43052544 to your computer and use it in GitHub Desktop.
import React from 'react'
class Input extends React.Component {
onChange = (evt) => {
const { onChange } = this.props
const { value } = evt.target
if (onChange) {
onChange(value)
}
}
render() {
const {
value,
error,
} = this.props
const className = error ? 'error' : ''
return (
<input
className={className}
value={value}
onChange={this.onChange}
/>
)
}
}
export default Input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment