Skip to content

Commit 14704ad

Browse files
committed
fix forwardref
1 parent 66715c5 commit 14704ad

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

‎frontend/main/src/layout/AppMenu.tsx‎

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import ActiveLink from '@/components/ActiveLink';
22
import TitleLogo from '@/components/global/logos/TitleLogo';
33
import OutsideClick from '@/components/OutsideClick';
44
import dynamic from 'next/dynamic';
5-
import { Dispatch, LegacyRef, SetStateAction, useEffect, useRef } from 'react';
5+
import {
6+
Dispatch,
7+
forwardRef,
8+
LegacyRef,
9+
SetStateAction,
10+
useEffect,
11+
useRef,
12+
} from 'react';
613
import { useSigninCheck } from 'reactfire';
714

815
const AvatarMenu = dynamic<any>(() => import('@/components/user/AvatarMenu'), {
@@ -29,31 +36,34 @@ export default function AppMenu({
2936
}
3037
}, [overlayMenuActive]);
3138

32-
const Link = ({
33-
href,
34-
comparison,
35-
name,
36-
ref,
37-
}: {
38-
href: string;
39-
comparison: string;
40-
name: string;
41-
ref?: LegacyRef<HTMLAnchorElement> | undefined;
42-
}) => {
39+
const LinkItem = (
40+
{
41+
href,
42+
comparison,
43+
name,
44+
}: {
45+
href: string;
46+
comparison: string;
47+
name: string;
48+
},
49+
ref: LegacyRef<HTMLAnchorElement> | null
50+
) => {
4351
return (
4452
<ActiveLink
4553
activeClassName="bg-primary-500 rounded-sm"
4654
href={href}
4755
comparison={comparison}
4856
>
49-
<a className="p-2 links-secondary hover:bg-primary-500">
57+
<a className="p-2 links-secondary hover:bg-primary-500" ref={ref}>
5058
<span className="sr-only">{`${name}`}</span>
5159
{name}
5260
</a>
5361
</ActiveLink>
5462
);
5563
};
5664

65+
const Link = forwardRef(LinkItem);
66+
5767
return (
5868
<div
5969
className={`${

0 commit comments

Comments
 (0)