UNPKG

@100mslive/roomkit-react

Version:

![Banner](https://github.com/100mslive/web-sdks/blob/06c65259912db6ccd8617f2ecb6fef51429251ec/prebuilt-banner.png)

25 lines (22 loc) 811 B
import { useEffect } from 'react'; // @ts-ignore: No implicit Any import { useSetAppDataByKey } from '../AppData/useUISettings'; import { APP_DATA } from '../../common/constants'; export const useDropdownList = ({ name, open }: { name: string; open: boolean }) => { const [dropdownList = [], setDropdownList] = useSetAppDataByKey(APP_DATA.dropdownList); useEffect(() => { if (open) { if (!dropdownList.includes(name)) { setDropdownList([...dropdownList, name]); } } else { const index = dropdownList.indexOf(name); if (index >= 0) { const newDropdownList = [...dropdownList]; newDropdownList.splice(index, 1); setDropdownList(newDropdownList); } } // eslint-disable-next-line react-hooks/exhaustive-deps }, [open, name]); };