'use client'; import { IconType } from 'react-icons/lib'; import { ActionIcon, Anchor, Stack, Text } from '@mantine/core'; import Link from 'next/link'; import { ReactElement, isValidElement } from 'react'; import { usePathname } from 'next/navigation'; import { useNavbarContext } from '@/providers/navbar'; import { useWebHaptics } from 'web-haptics/react'; interface Props { href: string; title?: string; icon: IconType | ReactElement; } export default function BottomBarItem(props: Props) { const pathname = usePathname(); const isActive = pathname === props.href; const { toggleMobile, mobileOpened } = useNavbarContext(); const { trigger } = useWebHaptics(); const renderIcon = () => { // If the icon is already a React element, just return it if (isValidElement(props.icon)) return props.icon; // Otherwise, it's an IconType component, so render it manually const IconComponent = props.icon as IconType; return ; }; return ( { trigger(); if (mobileOpened) { toggleMobile(); } }} > {renderIcon()} {props.title && ( {props.title} )} ); }