Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove forwardRef on Link #1863

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions packages/odyssey-react-mui/src/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
* See the License for the specific language governing permissions and limitations under the License.
*/

import { forwardRef, memo, ReactElement } from "react";

import { memo, ReactElement } from "react";
import { ExternalLinkIcon } from "./iconDictionary";

import { Link as MuiLink } from "@mui/material";
Expand All @@ -27,20 +26,18 @@ export type LinkProps = {
variant?: (typeof linkVariantValues)[number];
};

const Link = forwardRef<HTMLAnchorElement, LinkProps>(
({ icon, children, target, variant, href, rel }, ref) => (
<MuiLink href={href} ref={ref} rel={rel} target={target} variant={variant}>
{icon && <span className="Link-icon">{icon}</span>}
const Link = ({ icon, children, target, variant, href, rel }: LinkProps) => (
<MuiLink href={href} rel={rel} target={target} variant={variant}>
{icon && <span className="Link-icon">{icon}</span>}

{children}
{children}

{target === "_blank" && (
<span className="Link-indicator" role="presentation">
<ExternalLinkIcon />
</span>
)}
</MuiLink>
)
{target === "_blank" && (
<span className="Link-indicator" role="presentation">
<ExternalLinkIcon />
</span>
)}
</MuiLink>
);

const MemoizedLink = memo(Link);
Expand Down