Skip to content

Commit

Permalink
Add AsyncLink component
Browse files Browse the repository at this point in the history
  • Loading branch information
kamarmack committed Dec 28, 2023
1 parent 1a70d5a commit 25e364f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/components/custom-ui/async-link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Link, { LinkProps } from 'next/link';
import cn from '../../lib/cn';
import { BaseComponentWithChildren } from '../../types/BaseComponentTypes';

export type AsyncLinkProps = BaseComponentWithChildren &
LinkProps & {
isReady?: boolean;
key?: string;
};
export const AsyncLink: React.FC<AsyncLinkProps> = ({
children,
className = '',
isReady = true,
key,
...props
}) => {
if (!isReady) {
return (
<div className={cn(className)} key={key}>
{children}
</div>
);
}

return (
<Link {...props}>
<div className={cn(className)}>{children}</div>
</Link>
);
};

0 comments on commit 25e364f

Please sign in to comment.