How i can implement multiple select behavior If i start selected from one section, the another section will get disabled from selection. I tried many methods for do it but, i faced problem in logic how can implement it.
export default function App() {
const [datas, setDatas] = React.useState(initialState);
const [selectedItems, setSelectedItems] = React.useState([]);
const onChange = option => {
setSelectedItems(option);
// code here
};
function tagRender(props) {
const { value, closable, onClose } = props;
return (
<Tag
color="blue"
closable={closable}
onClose={onClose}
style={{ marginRight: 3 }}
>
{value}
</Tag>
);
}
return (
<Select
mode="multiple"
value={selectedItems}
tagRender={tagRender}
style={{ width: "100%" }}
onChange={onChange}
menuItemSelectedIcon={null}
>
{datas.map(data => (
<OptGroup label={data.groupName} key={data.groupName}>
{data.options.map(option => (
<Option value={option.value} key={option.value}>
<Checkbox
style={{ pointerEvents: "none" }}
type="checkbox"
checked={selectedItems.indexOf(option.value) !== -1}
>
{option.value}
</Checkbox>
</Option>
))}
</OptGroup>
))}
</Select>
);
}