add optionValues to the DropDow component

This commit is contained in:
Mohamed Karray
2019-03-28 10:13:56 +01:00
parent 58d2a03498
commit 98f98d123d

View File

@@ -5,6 +5,7 @@ import classNames from "classnames";
type Props = { type Props = {
options: string[], options: string[],
optionValues?: string[],
optionSelected: string => void, optionSelected: string => void,
preselectedOption?: string, preselectedOption?: string,
className: any, className: any,
@@ -13,7 +14,7 @@ type Props = {
class DropDown extends React.Component<Props> { class DropDown extends React.Component<Props> {
render() { render() {
const { options, preselectedOption, className, disabled } = this.props; const { options, optionValues, preselectedOption, className, disabled } = this.props;
return ( return (
<div className={classNames(className, "select")}> <div className={classNames(className, "select")}>
<select <select
@@ -22,9 +23,9 @@ class DropDown extends React.Component<Props> {
disabled={disabled} disabled={disabled}
> >
<option key="" /> <option key="" />
{options.map(option => { {options.map((option, index) => {
return ( return (
<option key={option} value={option}> <option key={option} value={optionValues && optionValues[index] ? optionValues[index] : option}>
{option} {option}
</option> </option>
); );