28 lines
624 B
TypeScript
28 lines
624 B
TypeScript
import React, { PureComponent } from 'react';
|
|
|
|
interface Props {
|
|
value?: string;
|
|
options: string[];
|
|
onChange(event: React.FormEvent<HTMLSpanElement>): void;
|
|
}
|
|
|
|
export default class SimpleSelect extends PureComponent<Props, {}> {
|
|
public render() {
|
|
return (
|
|
<select
|
|
value={this.props.value || this.props.options[0]}
|
|
className={'form-control'}
|
|
onChange={this.props.onChange}
|
|
>
|
|
{this.props.options.map((obj, i) => {
|
|
return (
|
|
<option value={obj} key={i}>
|
|
{obj}
|
|
</option>
|
|
);
|
|
})}
|
|
</select>
|
|
);
|
|
}
|
|
}
|