fixed value of SelectList

This commit is contained in:
[poww10s]
2020-11-18 02:57:38 -05:00
parent 45bc4aae55
commit 44274e495a
+8 -10
View File
@@ -3,17 +3,15 @@ import { useSelector, useDispatch } from 'react-redux';
import { selectById, parameterUpdated } from './parameterSlice.js'; import { selectById, parameterUpdated } from './parameterSlice.js';
const SelectList = (props) => { const SelectList = (props) => {
const options = props.list.map((option) => const options = props.list.map((option, index) => (
option === props.value ? ( <option value={option} key={index}>
<option value={option} selected> {option}
{option} </option>
</option> ));
) : (
<option value={option}>{option}</option>
)
);
return ( return (
<select onChange={(e) => props.onChange(e.target.value)}> <select
value={props.value}
onChange={(e) => props.onChange(e.target.value)}>
{options} {options}
</select> </select>
); );