Skip to content

Commit

Permalink
chore: forwardRef from SideNavigationLink component
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryanporwal committed Aug 22, 2024
1 parent 2339e4c commit 1ec4e5f
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { forwardRef } from "react";
import classNames from "classnames";
import type { HTMLProps } from "react";

Expand All @@ -17,23 +17,21 @@ export type Props<L = LinkDefaultElement> = Omit<
*/
component?: SideNavigationBaseProps<L>["component"];
};

const SideNavigationLink = <L = LinkDefaultElement,>({
component,
...props
}: Props<L>) => {
let className: string | null = null;
if ("className" in props && typeof props.className === "string") {
className = props.className;
delete props.className;
const SideNavigationLink = forwardRef<HTMLAnchorElement, Props>(
({ component, ref, ...props }: Props) => {
let className: string | null = null;
if ("className" in props && typeof props.className === "string") {
className = props.className;
delete props.className;
}
return (
<SideNavigationBase
className={classNames("p-side-navigation__link", className)}
component={component ?? "a"}
{...props}
/>
);
}
return (
<SideNavigationBase
className={classNames("p-side-navigation__link", className)}
component={component ?? "a"}
{...props}
/>
);
};
);

export default SideNavigationLink;

0 comments on commit 1ec4e5f

Please sign in to comment.