How should I disable specific options from react-select isMulti based on the condition provided.
import Select from 'react-select'
const Systems = () => {
const [dataSystems, setdataSystems] = useState([])
const [systemDetails, setsystemDetails] = useState({
SYSTEMID: 1,
......
})
const getSystems = async() => {
await axios.get('/API')
.then(response => {
setdataSystems(response.data)
})
}
const [multiSelected, setmultiSelected] = useState();
var handleMultiSelect = (e) => {
setmultiSelected(Array.isArray(e)?e.map(x=> x.value):[]);
}
const bodyInsertDepSystem = (
.......
<Select
isMulti
options = {dataSystems.map(e => ({ label: e.SYSTEMALIAS, value: e.SYSTEMID }))}
onChange = {handleMultiSelect} > </Select>
)
}
What I want to do is to remove the disable the SYSTEMID from the dropdown that has same ID as systemDetails.SYSTEMID.
Hope that you can help me with this.
What I really doing on this: During edit I want to relate one SYSTEMID to multiple SYSTEMID but I want to disable or remove that has same SYSTEMID
<Select
isMulti
options = {dataSystems.map(e => ({
label: e.SYSTEMALIAS,
value: e.SYSTEMID
isDisabled: e.SYSTEMID == systemDetails.SYSTEMID ? true: null
}))}
onChange = {handleMultiSelect}>
</Select>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.