Skip to content

Commit 2b4cd8b

Browse files
Merge branch 'main' of https://github.com/reactjs/react.dev into sync-b9eea4da
2 parents 63854cd + b9eea4d commit 2b4cd8b

File tree

15 files changed

+28
-36
lines changed

15 files changed

+28
-36
lines changed

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"plugins": ["@typescript-eslint"],
66
"rules": {
77
"no-unused-vars": "off",
8-
"@typescript-eslint/no-unused-vars": "warn"
8+
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "^_" }],
9+
"react-hooks/exhaustive-deps": "error"
910
},
1011
"env": {
1112
"node": true,

src/components/Layout/HomeContent.js

+12-20
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import {
88
useState,
99
useContext,
1010
useId,
11-
Fragment,
1211
Suspense,
1312
useEffect,
1413
useRef,
1514
useTransition,
16-
useReducer,
1715
} from 'react';
1816
import cn from 'classnames';
1917
import NextLink from 'next/link';
@@ -26,7 +24,6 @@ import {IconSearch} from 'components/Icon/IconSearch';
2624
import {Logo} from 'components/Logo';
2725
import Link from 'components/MDX/Link';
2826
import CodeBlock from 'components/MDX/CodeBlock';
29-
import {IconNavArrow} from 'components/Icon/IconNavArrow';
3027
import {ExternalLink} from 'components/ExternalLink';
3128
import sidebarBlog from '../../sidebarBlog.json';
3229

@@ -67,14 +64,6 @@ function Para({children}) {
6764
);
6865
}
6966

70-
function Left({children}) {
71-
return (
72-
<div className="px-5 lg:px-0 max-w-4xl lg:text-left text-white text-opacity-80">
73-
{children}
74-
</div>
75-
);
76-
}
77-
7867
function Center({children}) {
7968
return (
8069
<div className="px-5 lg:px-0 max-w-4xl lg:text-center text-white text-opacity-80 flex flex-col items-center justify-center">
@@ -90,19 +79,23 @@ function FullBleed({children}) {
9079
}
9180

9281
function CurrentTime() {
93-
const msPerMinute = 60 * 1000;
94-
const date = new Date();
95-
let nextMinute = Math.floor(+date / msPerMinute + 1) * msPerMinute;
96-
82+
const [date, setDate] = useState(new Date());
9783
const currentTime = date.toLocaleTimeString([], {
9884
hour: 'numeric',
9985
minute: 'numeric',
10086
});
101-
let [, forceUpdate] = useReducer((n) => n + 1, 0);
10287
useEffect(() => {
103-
const timeout = setTimeout(forceUpdate, nextMinute - Date.now());
88+
const msPerMinute = 60 * 1000;
89+
let nextMinute = Math.floor(+date / msPerMinute + 1) * msPerMinute;
90+
91+
const timeout = setTimeout(() => {
92+
if (Date.now() > nextMinute) {
93+
setDate(new Date());
94+
}
95+
}, nextMinute - Date.now());
10496
return () => clearTimeout(timeout);
10597
}, [date]);
98+
10699
return <span suppressHydrationWarning>{currentTime}</span>;
107100
}
108101

@@ -831,7 +824,7 @@ function ExampleLayout({
831824
.filter((s) => s !== null);
832825
setOverlayStyles(nextOverlayStyles);
833826
}
834-
}, [activeArea]);
827+
}, [activeArea, hoverTopOffset]);
835828
return (
836829
<div className="lg:pl-10 lg:pr-5 w-full">
837830
<div className="mt-12 mb-2 lg:my-16 max-w-7xl mx-auto flex flex-col w-full lg:rounded-2xl lg:bg-card lg:dark:bg-card-dark">
@@ -1211,7 +1204,7 @@ function useNestedScrollLock(ref) {
12111204
window.removeEventListener('scroll', handleScroll);
12121205
clearInterval(interval);
12131206
};
1214-
}, []);
1207+
}, [ref]);
12151208
}
12161209

12171210
function ExamplePanel({
@@ -1220,7 +1213,6 @@ function ExamplePanel({
12201213
noShadow,
12211214
height,
12221215
contentMarginTop,
1223-
activeArea,
12241216
}) {
12251217
return (
12261218
<div

src/components/Layout/Sidebar/SidebarLink.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function SidebarLink({
5454
ref={ref}
5555
title={title}
5656
target={target}
57+
passHref
5758
aria-current={selected ? 'page' : undefined}
5859
className={cn(
5960
'p-2 pr-2 w-full rounded-none lg:rounded-r-2xl text-left hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between',

src/components/Layout/SidebarNav/SidebarNav.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import {Suspense} from 'react';
66
import * as React from 'react';
77
import cn from 'classnames';
8-
import {Search} from 'components/Search';
98
import {Feedback} from '../Feedback';
109
import {SidebarRouteTree} from '../Sidebar/SidebarRouteTree';
1110
import type {RouteItem} from '../getRouteMeta';

src/components/Layout/TopNav/TopNav.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ import {IconSearch} from 'components/Icon/IconSearch';
2222
import {Search} from 'components/Search';
2323
import {Logo} from '../../Logo';
2424
import {Feedback} from '../Feedback';
25-
import {SidebarRouteTree} from '../Sidebar/SidebarRouteTree';
25+
import {SidebarRouteTree} from '../Sidebar';
2626
import type {RouteItem} from '../getRouteMeta';
27-
import {SidebarLink} from '../Sidebar';
2827

2928
declare global {
3029
interface Window {

src/components/Layout/getRouteMeta.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function getRouteMeta(cleanedPath: string, routeTree: RouteItem) {
6868
currentIndex: 0,
6969
};
7070
buildRouteMeta(cleanedPath, routeTree, ctx);
71-
const {currentIndex, ...meta} = ctx;
71+
const {currentIndex: _, ...meta} = ctx;
7272
return {
7373
...meta,
7474
breadcrumbs: breadcrumbs.length > 0 ? breadcrumbs : [routeTree],

src/components/MDX/BlogCard.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function BlogCard({title, badge, date, icon, url, children}: BlogCardProps) {
1818
return (
1919
<Link
2020
href={url as string}
21+
passHref
2122
className="block h-full w-full rounded-2xl outline-none focus:outline-none focus-visible:outline focus-visible:outline-link focus:outline-offset-2 focus-visible:dark:focus:outline-link-dark">
2223
<div className="justify-between p-5 sm:p-5 cursor-pointer w-full h-full flex flex-col flex-1 shadow-secondary-button-stroke dark:shadow-secondary-button-stroke-dark hover:bg-gray-40/5 active:bg-gray-40/10 hover:dark:bg-gray-60/5 active:dark:bg-gray-60/10 rounded-2xl text-xl text-primary dark:text-primary-dark leading-relaxed">
2324
<div className="flex flex-row gap-3 w-full">

src/components/MDX/MDXComponents.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ function YouTubeIframe(props: any) {
369369
}
370370

371371
function Image(props: any) {
372-
return <img className="max-w-[calc(min(700px,100%))]" {...props} />;
372+
const {alt, ...rest} = props;
373+
return <img alt={alt} className="max-w-[calc(min(700px,100%))]" {...rest} />;
373374
}
374375

375376
export const MDXComponents = {

src/components/MDX/Sandpack/CustomPreset.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const CustomPreset = memo(function CustomPreset({
5454

5555
const SandboxShell = memo(function SandboxShell({
5656
showDevTools,
57-
onDevToolsLoad,
5857
devToolsLoaded,
5958
providedFiles,
6059
lintErrors,

src/components/MDX/Sandpack/NavigationBar.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ export function NavigationBar({providedFiles}: {providedFiles: Array<string>}) {
9090
} else {
9191
return;
9292
}
93-
}, [isMultiFile]);
93+
94+
// Note: in a real useEvent, onContainerResize would be omitted.
95+
}, [isMultiFile, onContainerResize]);
9496

9597
const handleReset = () => {
9698
/**
9799
* resetAllFiles must come first, otherwise
98-
* the previous content will appears for a second
100+
* the previous content will appear for a second
99101
* when the iframe loads.
100102
*
101-
* Plus, it should only prompts if there's any file changes
103+
* Plus, it should only prompt if there's any file changes
102104
*/
103105
if (
104106
sandpack.editorState === 'dirty' &&

src/components/MDX/Sandpack/Preview.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export function Preview({
4949
errorScreenRegisteredRef,
5050
openInCSBRegisteredRef,
5151
loadingScreenRegisteredRef,
52-
status,
5352
} = sandpack;
5453

5554
if (

src/components/MDX/TeamMember.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Image from 'next/image';
77
import {IconTwitter} from '../Icon/IconTwitter';
88
import {IconGitHub} from '../Icon/IconGitHub';
99
import {ExternalLink} from '../ExternalLink';
10-
import {IconNewPage} from 'components/Icon/IconNewPage';
1110
import {H3} from './Heading';
1211
import {IconLink} from 'components/Icon/IconLink';
1312

src/components/Search.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import Head from 'next/head';
66
import Link from 'next/link';
77
import Router from 'next/router';
8-
import {lazy, useCallback, useEffect} from 'react';
8+
import {lazy, useEffect} from 'react';
99
import * as React from 'react';
1010
import {createPortal} from 'react-dom';
1111
import {siteConfig} from 'siteConfig';
12-
import cn from 'classnames';
1312

1413
export interface SearchProps {
1514
appId?: string;

src/content/reference/react/Component.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ Then you can wrap a part of your component tree with it:
13931393
13941394
If `Profile` or its child component throws an error, `ErrorBoundary` will "catch" that error, display a fallback UI with the error message you've provided, and send a production error report to your error reporting service.
13951395
1396-
You don't need to wrap every component into a separate error boundary. When you think about the [granularity of error boundaries,](https://aweary.dev/fault-tolerance-react/) consider where it makes sense to display an error message. For example, in a messaging app, it makes sense to place an error boundary around the list of conversations. It also makes sense to place one around every individual message. However, it wouldn't make sense to place a boundary around every avatar.
1396+
You don't need to wrap every component into a separate error boundary. When you think about the [granularity of error boundaries,](https://www.brandondail.com/posts/fault-tolerance-react) consider where it makes sense to display an error message. For example, in a messaging app, it makes sense to place an error boundary around the list of conversations. It also makes sense to place one around every individual message. However, it wouldn't make sense to place a boundary around every avatar.
13971397
13981398
<Note>
13991399

src/hooks/usePendingRoute.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const usePendingRoute = () => {
3333
events.off('routeChangeComplete', handleRouteChangeComplete);
3434
clearTimeout(routeTransitionTimer);
3535
};
36-
}, []);
36+
}, [events]);
3737

3838
return pendingRoute;
3939
};

0 commit comments

Comments
 (0)