Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Last active June 8, 2019 02:16
Show Gist options
  • Select an option

  • Save agoiabel/c5f1c1dc9b7e680488908fd2d2fb3e51 to your computer and use it in GitHub Desktop.

Select an option

Save agoiabel/c5f1c1dc9b7e680488908fd2d2fb3e51 to your computer and use it in GitHub Desktop.
import React from 'react';
const Select = props => {
let formControl = "form-control";
if (props.touched && !props.valid) {
formControl = 'form-control control-error';
}
return (
<div className="form-group">
<select className={formControl} value={props.value} onChange={props.onChange} name={props.name}>
{props.options.map(option => (
<option value={option.value}>
{option.displayValue}
</option>
))}
</select>
</div>
);
}
export default Select;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment