Skip to content

Commit 2c1e00a

Browse files
authored
Merge branch 'reactjs:main' into master
2 parents 3087e46 + f2101ab commit 2c1e00a

28 files changed

+18074
-28
lines changed
Loading
Loading
Binary file not shown.
Loading
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*/
4+
5+
import {memo} from 'react';
6+
7+
export const IconExperimental = memo<
8+
JSX.IntrinsicElements['svg'] & {title?: string; size?: 's' | 'md'}
9+
>(function IconCanary(
10+
{className, title, size} = {
11+
className: undefined,
12+
title: undefined,
13+
size: 'md',
14+
}
15+
) {
16+
return (
17+
<svg
18+
className={className}
19+
width={size === 's' ? '12px' : '20px'}
20+
height={size === 's' ? '12px' : '20px'}
21+
viewBox="0 0 20 20"
22+
version="1.1"
23+
xmlns="http://www.w3.org/2000/svg">
24+
{title && <title>{title}</title>}
25+
<g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
26+
<g
27+
id="noun-labs-1201738-(2)"
28+
transform="translate(2, 0)"
29+
fill="currentColor"
30+
fillRule="nonzero">
31+
<path
32+
d="M10.2865804,5.55665262 L10.2865804,2.22331605 L10.8591544,2.22331605 C11.0103911,2.22244799 11.1551447,2.16342155 11.2617505,2.05914367 C11.3684534,1.95486857 11.4282767,1.81370176 11.4282767,1.66667106 L11.4282767,0.556642208 C11.4282767,0.40907262 11.3678934,0.26747526 11.2605218,0.16308627 C11.1531503,0.0587028348 11.0074938,0 10.8556998,0 L5.14338868,0 C4.9915947,0 4.84594391,0.0587028348 4.73856664,0.16308627 C4.63119507,0.267469704 4.57081178,0.40907262 4.57081178,0.556642208 L4.57081178,1.66667106 C4.57081178,1.81434899 4.63119507,1.95594912 4.73856664,2.06033811 C4.8459382,2.16472155 4.9915947,2.22331605 5.14338868,2.22331605 L5.71596273,2.22331605 L5.71596273,5.55665262 C5.71596273,8.38665538 2.97295619,9.88999017 0.651686904,15.5566623 C-0.0957823782,17.360053 -2.00560068,20 7.99951567,20 C18.004632,20 16.0948137,17.3600252 15.3507732,15.5566623 C13.0124432,9.88999017 10.2865804,8.38665538 10.2865804,5.55665262 Z M9.89570197,10.709991 C10.0921412,10.709991 10.2805515,10.7858383 10.4193876,10.9209301 C10.5583466,11.0559135 10.6363652,11.2390693 10.6363652,11.4300417 C10.6363652,11.6210141 10.5583466,11.8040698 10.4193876,11.9391533 C10.2805401,12.0741367 10.0921412,12.1499813 9.89570197,12.1499813 C9.6992627,12.1499813 9.51096673,12.074134 9.37201631,11.9391533 C9.23316875,11.8040615 9.15515307,11.6210141 9.15515307,11.4300417 C9.15515307,11.2390693 9.2331716,11.0559024 9.37201631,10.9209301 C9.57264221,10.7258996 9.61239426,10.709991 9.89570197,10.709991 Z M8.98919546,9.04212824 C9.09790709,9.14792278 9.15884755,9.29158681 9.1585213,9.44110085 C9.15829001,9.59073155 9.09678989,9.73407335 8.98763252,9.83954568 C8.87847514,9.945018 8.73069852,10.0039347 8.57678157,10.0033977 C8.42286747,10.0027392 8.27565088,9.94273467 8.16727355,9.83639845 C8.05900765,9.73006224 7.99873866,9.58628988 7.99963013,9.43664806 C8.00052304,9.28788403 8.0620221,9.14542556 8.17051087,9.04048101 C8.27911107,8.93555591 8.42599335,8.87663641 8.57913312,8.87663641 C8.73291864,8.87665585 8.88047525,8.93622535 8.98919546,9.04212824 Z M7.99965585,17.9999981 C4.91377349,17.9999981 3.29882839,17.7332867 2.51364277,17.4999976 C2.37780966,17.4476975 2.26954376,17.3439641 2.21396931,17.2125528 C2.15838628,17.0811499 2.16006066,16.9334692 2.21876871,16.8033858 C2.6144474,15.5921346 3.14916224,14.4280501 3.81316983,13.3333824 C5.980145,9.82337899 8.22941036,13.8867718 10.0980836,13.8867718 C11.9666996,13.8867718 11.4695868,12.1534924 12.1827971,13.3333824 C12.8511505,14.4269112 13.3916656,15.5896902 13.794259,16.8000524 C13.8533022,16.9322137 13.8537479,17.0822749 13.7952635,17.2147751 C13.7368889,17.3472613 13.6248314,17.4504531 13.4856467,17.5000531 C12.6833967,17.7332867 11.0855382,17.9999981 7.99965585,17.9999981 Z"
33+
id="Shape"></path>
34+
</g>
35+
</g>
36+
</svg>
37+
);
38+
});

src/components/Layout/Page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface PageProps {
3131
meta: {
3232
title?: string;
3333
titleForTitleTag?: string;
34-
canary?: boolean;
34+
version?: 'experimental' | 'canary';
3535
description?: string;
3636
};
3737
section: 'learn' | 'reference' | 'community' | 'blog' | 'home' | 'unknown';
@@ -53,7 +53,7 @@ export function Page({
5353
routeTree
5454
);
5555
const title = meta.title || route?.title || '';
56-
const canary = meta.canary || false;
56+
const version = meta.version;
5757
const description = meta.description || route?.description || '';
5858
const isHomePage = cleanedPath === '/';
5959
const isBlogIndex = cleanedPath === '/blog';
@@ -70,7 +70,7 @@ export function Page({
7070
)}>
7171
<PageHeading
7272
title={title}
73-
canary={canary}
73+
version={version}
7474
description={description}
7575
tags={route?.tags}
7676
breadcrumbs={breadcrumbs}

src/components/Layout/Sidebar/SidebarLink.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import * as React from 'react';
99
import cn from 'classnames';
1010
import {IconNavArrow} from 'components/Icon/IconNavArrow';
1111
import {IconCanary} from 'components/Icon/IconCanary';
12+
import {IconExperimental} from 'components/Icon/IconExperimental';
1213
import Link from 'next/link';
1314

1415
interface SidebarLinkProps {
1516
href: string;
1617
selected?: boolean;
1718
title: string;
1819
level: number;
19-
version?: 'canary' | 'major';
20+
version?: 'canary' | 'major' | 'experimental';
2021
icon?: React.ReactNode;
2122
isExpanded?: boolean;
2223
hideArrow?: boolean;
@@ -84,7 +85,13 @@ export function SidebarLink({
8485
)}
8586
{version === 'canary' && (
8687
<IconCanary
87-
title=" - This feature is available in the latest Canary"
88+
title=" - This feature is available in the latest Canary version of React"
89+
className="ms-1 text-gray-30 dark:text-gray-60 inline-block w-3.5 h-3.5 align-[-3px]"
90+
/>
91+
)}
92+
{version === 'experimental' && (
93+
<IconExperimental
94+
title=" - This feature is available in the latest Experimental version of React"
8895
className="ms-1 text-gray-30 dark:text-gray-60 inline-block w-3.5 h-3.5 align-[-3px]"
8996
/>
9097
)}

src/components/MDX/ExpandableCallout.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type CalloutVariants =
1616
| 'note'
1717
| 'wip'
1818
| 'canary'
19+
| 'experimental'
1920
| 'major'
2021
| 'rsc';
2122

@@ -51,6 +52,15 @@ const variantMap = {
5152
overlayGradient:
5253
'linear-gradient(rgba(245, 249, 248, 0), rgba(245, 249, 248, 1)',
5354
},
55+
experimental: {
56+
title: 'Experimental Feature',
57+
Icon: IconCanary,
58+
containerClasses:
59+
'bg-green-5 dark:bg-green-60 dark:bg-opacity-20 text-primary dark:text-primary-dark text-lg',
60+
textColor: 'text-green-60 dark:text-green-40',
61+
overlayGradient:
62+
'linear-gradient(rgba(245, 249, 248, 0), rgba(245, 249, 248, 1)',
63+
},
5464
pitfall: {
5565
title: '陷阱',
5666
Icon: IconPitfall,

src/components/MDX/MDXComponents.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ const Canary = ({children}: {children: React.ReactNode}) => (
9898
<ExpandableCallout type="canary">{children}</ExpandableCallout>
9999
);
100100

101+
const Experimental = ({children}: {children: React.ReactNode}) => (
102+
<ExpandableCallout type="experimental">{children}</ExpandableCallout>
103+
);
104+
101105
const NextMajor = ({children}: {children: React.ReactNode}) => (
102106
<ExpandableCallout type="major">{children}</ExpandableCallout>
103107
);
@@ -120,6 +124,20 @@ const CanaryBadge = ({title}: {title: string}) => (
120124
</span>
121125
);
122126

127+
const ExperimentalBadge = ({title}: {title: string}) => (
128+
<span
129+
title={title}
130+
className={
131+
'text-base font-display px-1 py-0.5 font-bold bg-gray-10 dark:bg-gray-60 text-gray-60 dark:text-gray-10 rounded'
132+
}>
133+
<IconCanary
134+
size="s"
135+
className={'inline me-1 mb-0.5 text-sm text-gray-60 dark:text-gray-10'}
136+
/>
137+
Experimental only
138+
</span>
139+
);
140+
123141
const NextMajorBadge = ({title}: {title: string}) => (
124142
<span
125143
title={title}
@@ -508,6 +526,8 @@ export const MDXComponents = {
508526
MathI,
509527
Note,
510528
Canary,
529+
Experimental,
530+
ExperimentalBadge,
511531
CanaryBadge,
512532
NextMajor,
513533
NextMajorBadge,

src/components/PageHeading.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import {H1} from './MDX/Heading';
88
import type {RouteTag, RouteItem} from './Layout/getRouteMeta';
99
import * as React from 'react';
1010
import {IconCanary} from './Icon/IconCanary';
11+
import {IconExperimental} from './Icon/IconExperimental';
1112

1213
interface PageHeadingProps {
1314
title: string;
14-
canary?: boolean;
15+
version?: 'experimental' | 'canary';
16+
experimental?: boolean;
1517
status?: string;
1618
description?: string;
1719
tags?: RouteTag[];
@@ -21,19 +23,26 @@ interface PageHeadingProps {
2123
function PageHeading({
2224
title,
2325
status,
24-
canary,
26+
version,
2527
tags = [],
2628
breadcrumbs,
2729
}: PageHeadingProps) {
30+
console.log('version', version);
2831
return (
2932
<div className="px-5 sm:px-12 pt-3.5">
3033
<div className="max-w-4xl ms-0 2xl:mx-auto">
3134
{breadcrumbs ? <Breadcrumbs breadcrumbs={breadcrumbs} /> : null}
3235
<H1 className="mt-0 text-primary dark:text-primary-dark -mx-.5 break-words">
3336
{title}
34-
{canary && (
37+
{version === 'canary' && (
3538
<IconCanary
36-
title=" - This feature is available in the latest Canary"
39+
title=" - This feature is available in the latest Canary version of React"
40+
className="ms-4 mt-1 text-gray-50 dark:text-gray-40 inline-block w-6 h-6 align-[-1px]"
41+
/>
42+
)}
43+
{version === 'experimental' && (
44+
<IconExperimental
45+
title=" - This feature is available in the latest Experimental version of React"
3746
className="ms-4 mt-1 text-gray-50 dark:text-gray-40 inline-block w-6 h-6 align-[-1px]"
3847
/>
3948
)}

src/content/blog/2025/04/21/react-compiler-rc.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,23 @@ During the RC period, we encourage all React users to try the compiler and provi
5757
As noted in the Beta announcement, React Compiler is compatible with React 17 and up. If you are not yet on React 19, you can use React Compiler by specifying a minimum target in your compiler config, and adding `react-compiler-runtime` as a dependency. You can find docs on this [here](https://react.dev/learn/react-compiler#using-react-compiler-with-react-17-or-18).
5858

5959
## Migrating from eslint-plugin-react-compiler to eslint-plugin-react-hooks {/*migrating-from-eslint-plugin-react-compiler-to-eslint-plugin-react-hooks*/}
60-
If you have already installed eslint-plugin-react-compiler, you can now remove it and use `eslint-plugin-react-hooks@^6.0.0-rc.1`. Many thanks to [@michaelfaith](https://bsky.app/profile/michael.faith) for contributing to this improvement!
60+
If you have already installed eslint-plugin-react-compiler, you can now remove it and use `eslint-plugin-react-hooks@6.0.0-rc.1`. Many thanks to [@michaelfaith](https://bsky.app/profile/michael.faith) for contributing to this improvement!
6161

6262
To install:
6363

6464
npm
6565
<TerminalBlock>
66-
{`npm install --save-dev eslint-plugin-react-hooks@^6.0.0-rc.1`}
66+
{`npm install --save-dev eslint-plugin-react-hooks@6.0.0-rc.1`}
6767
</TerminalBlock>
6868

6969
pnpm
7070
<TerminalBlock>
71-
{`pnpm add --save-dev eslint-plugin-react-hooks@^6.0.0-rc.1`}
71+
{`pnpm add --save-dev eslint-plugin-react-hooks@6.0.0-rc.1`}
7272
</TerminalBlock>
7373

7474
yarn
7575
<TerminalBlock>
76-
{`yarn add --dev eslint-plugin-react-hooks@^6.0.0-rc.1`}
76+
{`yarn add --dev eslint-plugin-react-hooks@6.0.0-rc.1`}
7777
</TerminalBlock>
7878

7979
```js
@@ -89,14 +89,16 @@ export default [
8989
];
9090
```
9191

92+
To enable the React Compiler rule, add `'react-hooks/react-compiler': 'error'` to your ESLint configuration.
93+
9294
The linter does not require the compiler to be installed, so there's no risk in upgrading eslint-plugin-react-hooks. We recommend everyone upgrade today.
9395

9496
## swc support (experimental) {/*swc-support-experimental*/}
9597
React Compiler can be installed across [several build tools](/learn/react-compiler#installation) such as Babel, Vite, and Rsbuild.
9698

97-
In addition to those tools, we have been collaborating with Kang Dongyoong ([@kdy1dev](https://x.com/kdy1dev)) from the [swc](https://swc.rs/) team on adding additional support for React Compiler as an swc plugin. As part of the RC release, you can now integrate the compiler into your [Next.js app with swc](https://nextjs.org/docs/app/api-reference/config/next-config-js/reactCompiler) instead of Babel.
99+
In addition to those tools, we have been collaborating with Kang Dongyoon ([@kdy1dev](https://x.com/kdy1dev)) from the [swc](https://swc.rs/) team on adding additional support for React Compiler as an swc plugin. While this work isn't done, Next.js build performance should now be considerably faster when the [React Compiler is enabled in your Next.js app](https://nextjs.org/docs/app/api-reference/config/next-config-js/reactCompiler).
98100

99-
Next.js users can upgrade to [15.3.1](https://github.com/vercel/next.js/releases/tag/v15.3.1) or greater to try this out. If you have already enabled the compiler in your Next.js's config, swc support will be enabled automatically.
101+
We recommend using Next.js [15.3.1](https://github.com/vercel/next.js/releases/tag/v15.3.1) or greater to get the best build performance.
100102

101103
Vite users can continue to use [vite-plugin-react](https://github.com/vitejs/vite-plugin-react) to enable the compiler, by adding it as a [Babel plugin](https://react.dev/learn/react-compiler#usage-with-vite). We are also working with the [oxc](https://oxc.rs/) team to [add support for the compiler](https://github.com/oxc-project/oxc/issues/10048). Once [rolldown](https://github.com/rolldown/rolldown) is officially released and supported in Vite and oxc support is added for React Compiler, we'll update the docs with information on how to migrate.
102104

0 commit comments

Comments
 (0)