fixed value of SelectList
This commit is contained in:
@@ -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>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user