Skip to content

Instantly share code, notes, and snippets.

@stelmakh
Created December 30, 2018 10:03
Show Gist options
  • Select an option

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

Select an option

Save stelmakh/9b8ac4c4951400dbf3ad4c7d0d36ec43 to your computer and use it in GitHub Desktop.
import React from 'react'
import './index.css'
class Input extends React.Component {
onChange = (evt) => {
const { onChange, disabled } = this.props
const { value } = evt.target
if (!disabled && onChange) {
onChange(value)
}
}
render() {
const {
value,
error,
disabled,
} = this.props
let className = 'input '
if (error) {
className += 'error '
}
if (disabled) {
className += 'disabled '
}
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