diff --git a/package.json b/package.json index 53a8d16..b743fdc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-accessible-dropdown-menu-hook", - "version": "2.2.0", + "version": "2.2.1", "description": "A simple Hook for creating fully accessible dropdown menus in React", "main": "dist/use-dropdown-menu.js", "types": "dist/use-dropdown-menu.d.ts", diff --git a/src/use-dropdown-menu.ts b/src/use-dropdown-menu.ts index 8126a90..4b22e9e 100644 --- a/src/use-dropdown-menu.ts +++ b/src/use-dropdown-menu.ts @@ -36,7 +36,7 @@ export default function useDropdownMenu(itemCount: number): DropdownMenuResponse // Initialize refs and update them when the item count changes useEffect(() => { - itemRefs.current = [...Array(itemCount)].map(() => createRef()); + itemRefs.current = Array.from({ length: itemCount }, () => createRef()); }, [itemCount]); // Create type guard @@ -199,7 +199,7 @@ export default function useDropdownMenu(itemCount: number): DropdownMenuResponse 'aria-expanded': isOpen, }; - const itemProps = [...Array(itemCount)].map((_ignore, index) => ({ + const itemProps = Array.from({ length: itemCount }, (_ignore, index) => ({ onKeyDown: itemListener, tabIndex: -1, role: 'menuitem',