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

[docs] Fix element.ref accessing warning on docs #45155

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Update examples accordingly
DiegoAndai committed Jan 30, 2025
commit 9dc22538dd697f356252e42fd5b08ff0897b5907
25 changes: 4 additions & 21 deletions examples/material-ui-nextjs-pages-router-ts/src/Link.tsx
Original file line number Diff line number Diff line change
@@ -3,10 +3,6 @@ import clsx from 'clsx';
import { useRouter } from 'next/router';
import NextLink, { LinkProps as NextLinkProps } from 'next/link';
import MuiLink, { LinkProps as MuiLinkProps } from '@mui/material/Link';
import { styled } from '@mui/material/styles';

// Add support for the sx prop for consistency with the other branches.
const Anchor = styled('a')({});

interface NextLinkComposedProps
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>,
@@ -17,17 +13,7 @@ interface NextLinkComposedProps

export const NextLinkComposed = React.forwardRef<HTMLAnchorElement, NextLinkComposedProps>(
function NextLinkComposed(props, ref) {
const {
to,
linkAs,
replace,
scroll,
shallow,
prefetch,
legacyBehavior = true,
locale,
...other
} = props;
const { to, linkAs, replace, scroll, shallow, prefetch, locale, ...other } = props;

return (
<NextLink
@@ -39,10 +25,9 @@ export const NextLinkComposed = React.forwardRef<HTMLAnchorElement, NextLinkComp
shallow={shallow}
passHref
locale={locale}
legacyBehavior={legacyBehavior}
>
<Anchor ref={ref} {...other} />
</NextLink>
ref={ref}
{...other}
/>
);
},
);
@@ -64,7 +49,6 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link(props,
as,
className: classNameProps,
href,
legacyBehavior,
linkAs: linkAsProp,
locale,
noLinkStyle,
@@ -90,7 +74,6 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link(props,
scroll,
shallow,
prefetch,
legacyBehavior,
locale,
};

25 changes: 4 additions & 21 deletions examples/material-ui-nextjs-pages-router/src/Link.js
Original file line number Diff line number Diff line change
@@ -3,23 +3,9 @@ import clsx from 'clsx';
import { useRouter } from 'next/router';
import NextLink from 'next/link';
import MuiLink from '@mui/material/Link';
import { styled } from '@mui/material/styles';

// Add support for the sx prop for consistency with the other branches.
const Anchor = styled('a')({});

export const NextLinkComposed = React.forwardRef(function NextLinkComposed(props, ref) {
const {
to,
linkAs,
replace,
scroll,
shallow,
prefetch,
legacyBehavior = true,
locale,
...other
} = props;
const { to, linkAs, replace, scroll, shallow, prefetch, locale, ...other } = props;

return (
<NextLink
@@ -30,11 +16,10 @@ export const NextLinkComposed = React.forwardRef(function NextLinkComposed(props
scroll={scroll}
shallow={shallow}
passHref
legacyBehavior={legacyBehavior}
locale={locale}
>
<Anchor ref={ref} {...other} />
</NextLink>
ref={ref}
{...other}
/>
);
});

@@ -46,7 +31,6 @@ const Link = React.forwardRef(function Link(props, ref) {
as,
className: classNameProps,
href,
legacyBehavior,
linkAs: linkAsProp,
locale,
noLinkStyle,
@@ -72,7 +56,6 @@ const Link = React.forwardRef(function Link(props, ref) {
scroll,
shallow,
prefetch,
legacyBehavior,
locale,
};