Another guard

This commit is contained in:
Lim Chee Aun 2023-02-19 10:56:28 +08:00
parent a27bdbc69b
commit 72068d9d46

View file

@ -23,8 +23,10 @@ function Shortcuts() {
const menuRef = useRef(); const menuRef = useRef();
const formattedShortcuts = shortcuts.map((pin, i) => { const formattedShortcuts = shortcuts
.map((pin, i) => {
const { type, ...data } = pin; const { type, ...data } = pin;
if (!SHORTCUTS_META[type]) return null;
let { path, title, icon } = SHORTCUTS_META[type]; let { path, title, icon } = SHORTCUTS_META[type];
if (typeof path === 'function') { if (typeof path === 'function') {
@ -42,7 +44,8 @@ function Shortcuts() {
title, title,
icon, icon,
}; };
}); })
.filter(Boolean);
const navigate = useNavigate(); const navigate = useNavigate();
useHotkeys(['1', '2', '3', '4', '5', '6', '7', '8', '9'], (e, handler) => { useHotkeys(['1', '2', '3', '4', '5', '6', '7', '8', '9'], (e, handler) => {