pref: 为 Link 组件添加 suppressHydrationWarning 属性- 在多个页面组件中,为 Link 组件添加 suppressHydrationWarning 属性

- 此修改可以抑制 React 的 Hydration 警告,提高应用的性能和用户体验
master
钟良源 6 months ago
parent 59ffa644ba
commit ab9124247f

@ -46,7 +46,7 @@ function Announcement() {
<Typography.Title heading={6}> <Typography.Title heading={6}>
{t['workplace.announcement']} {t['workplace.announcement']}
</Typography.Title> </Typography.Title>
<Link>{t['workplace.seeMore']}</Link> <Link suppressHydrationWarning>{t['workplace.seeMore']}</Link>
</div> </div>
<Skeleton loading={loading} text={{ rows: 5, width: '100%' }} animation> <Skeleton loading={loading} text={{ rows: 5, width: '100%' }} animation>
<div> <div>
@ -64,4 +64,4 @@ function Announcement() {
); );
} }
export default Announcement; export default Announcement;

@ -17,11 +17,11 @@ function QuickOperation() {
<Card> <Card>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography.Title heading={6}>{t['workplace.docs']}</Typography.Title> <Typography.Title heading={6}>{t['workplace.docs']}</Typography.Title>
<Link>{t['workplace.seeMore']}</Link> <Link suppressHydrationWarning>{t['workplace.seeMore']}</Link>
</div> </div>
<div className={styles.docs}> <div className={styles.docs}>
{Object.entries(links).map(([key, value]) => ( {Object.entries(links).map(([key, value]) => (
<Link className={styles.link} key={key} href={value} target="_blank"> <Link className={styles.link} key={key} href={value} target="_blank" suppressHydrationWarning>
{t[`workplace.${key}`]} {t[`workplace.${key}`]}
</Link> </Link>
))} ))}
@ -30,4 +30,4 @@ function QuickOperation() {
); );
} }
export default QuickOperation; export default QuickOperation;

@ -145,7 +145,7 @@ function Overview() {
({t['workplace.1year']}) ({t['workplace.1year']})
</span> </span>
</Typography.Paragraph> </Typography.Paragraph>
<Link>{t['workplace.seeMore']}</Link> <Link suppressHydrationWarning>{t['workplace.seeMore']}</Link>
</div> </div>
<OverviewAreaLine data={data.chartData} loading={loading} /> <OverviewAreaLine data={data.chartData} loading={loading} />
</div> </div>

@ -84,7 +84,7 @@ function PopularContent() {
<Typography.Title heading={6}> <Typography.Title heading={6}>
{t['workplace.popularContents']} {t['workplace.popularContents']}
</Typography.Title> </Typography.Title>
<Link>{t['workplace.seeMore']}</Link> <Link suppressHydrationWarning>{t['workplace.seeMore']}</Link>
</div> </div>
<Radio.Group <Radio.Group
type="button" type="button"

@ -82,7 +82,7 @@ function Shortcuts() {
<Typography.Title heading={6}> <Typography.Title heading={6}>
{t['workplace.shortcuts']} {t['workplace.shortcuts']}
</Typography.Title> </Typography.Title>
<Link>{t['workplace.seeMore']}</Link> <Link suppressHydrationWarning>{t['workplace.seeMore']}</Link>
</div> </div>
<div className={styles.shortcuts}> <div className={styles.shortcuts}>
{shortcuts.map((shortcut) => ( {shortcuts.map((shortcut) => (
@ -114,4 +114,4 @@ function Shortcuts() {
); );
} }
export default Shortcuts; export default Shortcuts;

@ -11,7 +11,7 @@ import {
IconExclamationCircle, IconExclamationCircle,
IconUser, IconUser,
IconMenuFold, IconMenuFold,
IconMenuUnfold, IconMenuUnfold
} from '@arco-design/web-react/icon'; } from '@arco-design/web-react/icon';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
@ -146,8 +146,8 @@ function PageLayout({ children }: { children: ReactNode }) {
menuMap.current.set(route.key, { menuItem: true }); menuMap.current.set(route.key, { menuItem: true });
return ( return (
<MenuItem key={route.key}> <MenuItem key={route.key}>
<Link href={`/${route.key}`}> <Link href={`/${route.key}`} passHref>
<a>{titleDom}</a> <a suppressHydrationWarning>{titleDom}</a>
</Link> </Link>
</MenuItem> </MenuItem>
); );
@ -185,7 +185,7 @@ function PageLayout({ children }: { children: ReactNode }) {
<Layout className={styles.layout}> <Layout className={styles.layout}>
<div <div
className={cs(styles['layout-navbar'], { className={cs(styles['layout-navbar'], {
[styles['layout-navbar-hidden']]: !showNavbar, [styles['layout-navbar-hidden']]: !showNavbar
})} })}
> >
<Navbar show={showNavbar} /> <Navbar show={showNavbar} />

@ -111,7 +111,7 @@ export default function LoginForm() {
<Checkbox checked={rememberPassword} onChange={setRememberPassword}> <Checkbox checked={rememberPassword} onChange={setRememberPassword}>
{t['login.form.rememberPassword']} {t['login.form.rememberPassword']}
</Checkbox> </Checkbox>
<Link>{t['login.form.forgetPassword']}</Link> <Link suppressHydrationWarning>{t['login.form.forgetPassword']}</Link>
</div> </div>
<Button type="primary" long onClick={onSubmitClick} loading={loading}> <Button type="primary" long onClick={onSubmitClick} loading={loading}>
{t['login.form.login']} {t['login.form.login']}

@ -33,14 +33,14 @@ function Success() {
<ol> <ol>
<li> <li>
{t['error.detailLine.record']} {t['error.detailLine.record']}
<Link> <Link suppressHydrationWarning>
<IconLink /> <IconLink />
{t['error.detailLine.record.link']} {t['error.detailLine.record.link']}
</Link> </Link>
</li> </li>
<li> <li>
{t['error.detailLine.auth']} {t['error.detailLine.auth']}
<Link>{t['error.detailLine.auth.link']}</Link> <Link suppressHydrationWarning>{t['error.detailLine.auth.link']}</Link>
</li> </li>
</ol> </ol>
</Typography.Paragraph> </Typography.Paragraph>
@ -50,4 +50,4 @@ function Success() {
); );
} }
export default Success; export default Success;

@ -46,7 +46,7 @@ function UserInfo() {
<Title heading={6} style={{ marginBottom: '20px' }}> <Title heading={6} style={{ marginBottom: '20px' }}>
{t['userInfo.title.project']} {t['userInfo.title.project']}
</Title> </Title>
<Link>{t['userInfo.btn.more']}</Link> <Link suppressHydrationWarning>{t['userInfo.btn.more']}</Link>
</div> </div>
<MyProject /> <MyProject />
</Card> </Card>
@ -69,7 +69,7 @@ function UserInfo() {
<Title heading={6} style={{ marginBottom: '8px' }}> <Title heading={6} style={{ marginBottom: '8px' }}>
{t['userInfo.title.news']} {t['userInfo.title.news']}
</Title> </Title>
<Link>{t['userInfo.btn.all']}</Link> <Link suppressHydrationWarning>{t['userInfo.btn.all']}</Link>
</div> </div>
<LatestNews /> <LatestNews />
</Card> </Card>

@ -81,7 +81,7 @@ export default function Info({
{t['userSetting.value.notVerified']} {t['userSetting.value.notVerified']}
</Tag> </Tag>
)} )}
<Link role="button" className={styles['edit-btn']}> <Link role="button" className={styles['edit-btn']} suppressHydrationWarning>
{t['userSetting.btn.edit']} {t['userSetting.btn.edit']}
</Link> </Link>
</span> </span>
@ -98,7 +98,7 @@ export default function Info({
) : ( ) : (
<span> <span>
{userInfo.phoneNumber} {userInfo.phoneNumber}
<Link role="button" className={styles['edit-btn']}> <Link role="button" className={styles['edit-btn']} suppressHydrationWarning>
{t['userSetting.btn.edit']} {t['userSetting.btn.edit']}
</Link> </Link>
</span> </span>

@ -50,12 +50,13 @@ export default function Welcome() {
<Link <Link
target="_blank" target="_blank"
href="https://arco.design/material?category=arco-design-pro" href="https://arco.design/material?category=arco-design-pro"
suppressHydrationWarning
> >
{t['welcome.link.material-pro']} <IconDoubleRight /> {t['welcome.link.material-pro']} <IconDoubleRight />
</Link> </Link>
</div> </div>
<div style={{ marginTop: 8 }}> <div style={{ marginTop: 8 }}>
<Link target="_blank" href="https://arco.design/material"> <Link target="_blank" href="https://arco.design/material" suppressHydrationWarning>
{t['welcome.link.material-all']} <IconDoubleRight /> {t['welcome.link.material-all']} <IconDoubleRight />
</Link> </Link>
</div> </div>
@ -63,4 +64,4 @@ export default function Welcome() {
</div> </div>
</div> </div>
); );
} }
Loading…
Cancel
Save