Skip to content

Sync with react.dev @ 55986965 #832

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0bc6300
[ci] fix notify for forks (#7694)
rickhanlonii Mar 24, 2025
9b2ad17
[ci] Remove unused param (#7695)
poteto Mar 24, 2025
6788f6b
Fixes typo (#7688)
betovelandia Mar 24, 2025
2859efa
Add React Prague community (#7279)
pchalupa Mar 25, 2025
9f87530
Remove captureOwnerStack canary banner (#7701)
jackpope Mar 31, 2025
38ee8d2
Add note about StrictMode not as the root component (#7702)
rickhanlonii Mar 31, 2025
c0e1774
[errors] special case for 418 (#7705)
rickhanlonii Apr 1, 2025
b5f5134
update reactrouter url (#7703)
zongben Apr 1, 2025
06500ec
Typo correction (#7657)
SandwichGouda Apr 2, 2025
6a548a8
Use stable React by default in Sandpacks (#7709)
eps1lon Apr 2, 2025
b77c05d
Misc `captureOwnerStack` cleanup after stable release (#7710)
eps1lon Apr 2, 2025
b5c16dc
fix(reference): declare `subscribe` before passing it to the hook (#7…
hugmouse Apr 2, 2025
3dfa3bd
Fix heading links in StrictMode (#7713)
rickhanlonii Apr 2, 2025
9fc1221
Update meetups.md (#7700)
darshanyeah Apr 2, 2025
c74271e
Add React Denver to the Meetups page (#4727)
willklein Apr 2, 2025
0ea503b
typo (#7685)
pdurbin Apr 2, 2025
5138e60
Fix small grammatical mistake on Reusing Logic with Custom Hooks page…
LuckyT89 Apr 2, 2025
6ead1fa
Add note about `useId` being allowed in non-async Server Components (…
hernan-yadiel Apr 7, 2025
e148ffe
Add note about root.render microtask scheduling (#7717)
jukben Apr 8, 2025
420c2f6
Add React Conf banner (#7729)
mattcarrollcode Apr 8, 2025
5598696
Add React Conf to conferences.md and move past conferences (#7730)
mattcarrollcode Apr 9, 2025
3249e05
merging all conflicts
react-translations-bot Apr 14, 2025
eec3ae3
Resolve conflicts
smikitky Apr 14, 2025
0d7646f
Fix markup error that caused build error
smikitky Apr 16, 2025
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
3 changes: 1 addition & 2 deletions .github/workflows/discord_notify.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Discord Notify

on:
pull_request:
pull_request_target:
types: [opened, ready_for_review]

permissions: {}
Expand All @@ -14,7 +14,6 @@ jobs:
contents: read
with:
actor: ${{ github.event.pull_request.user.login }}
is_remote: true

notify:
if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/label_core_team_prs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Label Core Team PRs

on:
pull_request:
pull_request_target:

permissions: {}

Expand All @@ -18,7 +18,6 @@ jobs:
contents: read
with:
actor: ${{ github.event.pull_request.user.login }}
is_remote: true

label:
if: ${{ needs.check_maintainer.outputs.is_core_team == 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ module.exports = {
},
},
},
}
};
6 changes: 4 additions & 2 deletions public/js/jsfiddle-integration-babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

// Do not delete or move this file.
// Many fiddles reference it so we have to keep it here.
(function() {
(function () {
var tag = document.querySelector(
'script[type="application/javascript;version=1.7"]'
);
if (!tag || tag.textContent.indexOf('window.onload=function(){') !== -1) {
alert('Bad JSFiddle configuration, please fork the original React JSFiddle');
alert(
'Bad JSFiddle configuration, please fork the original React JSFiddle'
);
}
tag.setAttribute('type', 'text/babel');
tag.textContent = tag.textContent.replace(/^\/\/<!\[CDATA\[/, '');
Expand Down
6 changes: 4 additions & 2 deletions public/js/jsfiddle-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

// Do not delete or move this file.
// Many fiddles reference it so we have to keep it here.
(function() {
(function () {
var tag = document.querySelector(
'script[type="application/javascript;version=1.7"]'
);
if (!tag || tag.textContent.indexOf('window.onload=function(){') !== -1) {
alert('Bad JSFiddle configuration, please fork the original React JSFiddle');
alert(
'Bad JSFiddle configuration, please fork the original React JSFiddle'
);
}
tag.setAttribute('type', 'text/jsx;harmony=true');
tag.textContent = tag.textContent.replace(/^\/\/<!\[CDATA\[/, '');
Expand Down
4 changes: 2 additions & 2 deletions scripts/headingIDHelpers/walk.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const fs = require('fs');

module.exports = function walk(dir) {
let results = [];
/**
/**
* If the param is a directory we can return the file
*/
if(dir.includes('md')){
if (dir.includes('md')) {
return [dir];
}
const list = fs.readdirSync(dir);
Expand Down
4 changes: 2 additions & 2 deletions scripts/headingIdLinter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const validateHeaderIds = require('./headingIDHelpers/validateHeadingIDs');
const generateHeadingIds = require('./headingIDHelpers/generateHeadingIDs');

/**
/**
* yarn lint-heading-ids --> Checks all files and causes an error if heading ID is missing
* yarn lint-heading-ids --fix --> Fixes all markdown file's heading IDs
* yarn lint-heading-ids path/to/markdown.md --> Checks that particular file for missing heading ID (path can denote a directory or particular file)
* yarn lint-heading-ids --fix path/to/markdown.md --> Fixes that particular file's markdown IDs (path can denote a directory or particular file)
*/
*/

const markdownPaths = process.argv.slice(2);
if (markdownPaths.includes('--fix')) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Layout/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {useRouter} from 'next/router';
import {SidebarNav} from './SidebarNav';
import {Footer} from './Footer';
import {Toc} from './Toc';
// import SocialBanner from '../SocialBanner';
import SocialBanner from '../SocialBanner';
import {DocsPageFooter} from 'components/DocsFooter';
import {Seo} from 'components/Seo';
import PageHeading from 'components/PageHeading';
Expand Down Expand Up @@ -137,7 +137,7 @@ export function Page({
/>
</Head>
)}
{/*<SocialBanner />*/}
<SocialBanner />
<TopNav
section={section}
routeTree={routeTree}
Expand Down
29 changes: 17 additions & 12 deletions src/components/MDX/ErrorDecoder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function parseQueryString(search: string): Array<string | undefined> {
}

export default function ErrorDecoder() {
const {errorMessage} = useErrorDecoderParams();
const {errorMessage, errorCode} = useErrorDecoderParams();
/** error messages that contain %s require reading location.search */
const hasParams = errorMessage?.includes('%s');
const [message, setMessage] = useState<React.ReactNode | null>(() =>
Expand All @@ -82,23 +82,28 @@ export default function ErrorDecoder() {
if (errorMessage == null || !hasParams) {
return;
}
const args = parseQueryString(window.location.search);
let message = errorMessage;
if (errorCode === '418') {
// Hydration errors have a %s for the diff, but we don't add that to the args for security reasons.
message = message.replace(/%s$/, '');

setMessage(
urlify(
replaceArgs(
errorMessage,
parseQueryString(window.location.search),
'[missing argument]'
)
)
);
// Before React 19.1, the error message didn't have an arg, and was always HTML.
if (args.length === 0) {
args.push('HTML');
} else if (args.length === 1 && args[0] === '') {
args[0] = 'HTML';
}
}

setMessage(urlify(replaceArgs(message, args, '[missing argument]')));
setIsReady(true);
}, [hasParams, errorMessage]);
}, [errorCode, hasParams, errorMessage]);

return (
<code
className={cn(
'block bg-red-100 text-red-600 py-4 px-6 mt-5 rounded-lg',
'whitespace-pre-line block bg-red-100 text-red-600 py-4 px-6 mt-5 rounded-lg',
isReady ? 'opacity-100' : 'opacity-0'
)}>
<b>{message}</b>
Expand Down
4 changes: 2 additions & 2 deletions src/components/MDX/Sandpack/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ root.render(
eject: 'react-scripts eject',
},
dependencies: {
react: '19.0.0-rc-3edc000d-20240926',
'react-dom': '19.0.0-rc-3edc000d-20240926',
react: '^19.1.0',
'react-dom': '^19.1.0',
'react-scripts': '^5.0.0',
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/SocialBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {useRef, useEffect} from 'react';
import cn from 'classnames';
import {ExternalLink} from './ExternalLink';

const bannerText = 'Stream React Conf on May 15-16.';
const bannerText = 'Join us for React Conf on Oct 7-8.';
const bannerLink = 'https://conf.react.dev/';
const bannerLinkText = 'Learn more.';

Expand Down
25 changes: 15 additions & 10 deletions src/content/community/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ title: React カンファレンス

## Upcoming Conferences {/*upcoming-conferences*/}

### React Paris 2025 {/*react-paris-2025*/}
March 20 - 21, 2025. In-person in Paris, France (hybrid event)

[Website](https://react.paris/) - [Twitter](https://x.com/BeJS_)

### React Native Connection 2025 {/*react-native-connection-2025*/}
April 3 (Reanimated Training) + April 4 (Conference), 2025. Paris, France.

[Website](https://reactnativeconnection.io/) - [X](https://x.com/reactnativeconn) - [Bluesky](https://bsky.app/profile/reactnativeconnect.bsky.social)

### CityJS London 2025 {/*cityjs-london*/}
April 23 - 25, 2025. In-person in London, UK

Expand Down Expand Up @@ -50,6 +40,11 @@ September 2-4, 2025. Wrocław, Poland.

[Website](https://www.reactuniverseconf.com/) - [Twitter](https://twitter.com/react_native_eu) - [LinkedIn](https://www.linkedin.com/events/reactuniverseconf7163919537074118657/)

### React Conf 2025 {/*react-conf-2025*/}
October 7-8, 2025. Henderson, Nevada, USA and free livestream

[Website](https://conf.react.dev/) - [Twitter](https://x.com/reactjs) - [Bluesky](https://bsky.app/profile/react.dev)

### React India 2025 {/*react-india-2025*/}
October 31 - November 01, 2025. In-person in Goa, India (hybrid event) + Oct 15 2025 - remote day

Expand All @@ -58,6 +53,16 @@ October 31 - November 01, 2025. In-person in Goa, India (hybrid event) + Oct 15

## Past Conferences {/*past-conferences*/}

### React Paris 2025 {/*react-paris-2025*/}
March 20 - 21, 2025. In-person in Paris, France (hybrid event)

[Website](https://react.paris/) - [Twitter](https://x.com/BeJS_)

### React Native Connection 2025 {/*react-native-connection-2025*/}
April 3 (Reanimated Training) + April 4 (Conference), 2025. Paris, France.

[Website](https://reactnativeconnection.io/) - [X](https://x.com/reactnativeconn) - [Bluesky](https://bsky.app/profile/reactnativeconnect.bsky.social)

### React Day Berlin 2024 {/*react-day-berlin-2024*/}
December 13 & 16, 2024. In-person in Berlin, Germany + remote (hybrid event)

Expand Down
6 changes: 5 additions & 1 deletion src/content/community/meetups.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ title: React ミーティング
## Colombia {/*colombia*/}
* [Medellin](https://www.meetup.com/React-Medellin/)

## Czechia {/*czechia*/}
* [Prague](https://guild.host/react-prague/)

## Denmark {/*denmark*/}
* [Aalborg](https://www.meetup.com/Aalborg-React-React-Native-Meetup/)
* [Aarhus](https://www.meetup.com/Aarhus-ReactJS-Meetup/)
Expand Down Expand Up @@ -78,7 +81,7 @@ title: React ミーティング
* [Thessaloniki](https://www.meetup.com/Thessaloniki-ReactJS-Meetup/)

## India {/*india*/}
* [Ahmedabad](https://www.meetup.com/react-ahmedabad/)
* [Ahmedabad](https://reactahmedabad.dev/)
* [Bangalore (React)](https://www.meetup.com/ReactJS-Bangalore/)
* [Bangalore (React Native)](https://www.meetup.com/React-Native-Bangalore-Meetup)
* [Chennai](https://www.linkedin.com/company/chennaireact)
Expand Down Expand Up @@ -166,6 +169,7 @@ title: React ミーティング
* [Cleveland, OH - ReactJS](https://www.meetup.com/Cleveland-React/)
* [Columbus, OH - ReactJS](https://www.meetup.com/ReactJS-Columbus-meetup/)
* [Dallas, TX - ReactJS](https://www.meetup.com/ReactDallas/)
* [Denver, CO - React Denver](https://reactdenver.com/)
* [Detroit, MI - Detroit React User Group](https://www.meetup.com/Detroit-React-User-Group/)
* [Indianapolis, IN - React.Indy](https://www.meetup.com/React-Indy)
* [Irvine, CA - ReactJS](https://www.meetup.com/ReactJS-OC/)
Expand Down
2 changes: 1 addition & 1 deletion src/content/learn/build-a-react-app-from-scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ React エコシステムには、これらの問題に対するツールがた

以下のライブラリの使用をお勧めします。

- [React Router](https://reactrouter.com/start/framework/custom)
- [React Router](https://reactrouter.com/start/data/custom)
- [Tanstack Router](https://tanstack.com/router/latest)


Expand Down
2 changes: 1 addition & 1 deletion src/content/learn/reusing-logic-with-custom-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ export function useOnlineStatus() {

上記の例では、`useOnlineStatus` は [`useState`](/reference/react/useState) と [`useEffect`](/reference/react/useEffect) のペアで実装されています。しかし、これは最善のソリューションではありません。考慮されていないエッジケースがいくつかあります。例えば、コンポーネントがマウントされたとき `isOnline` は `true` であると仮定していますが、ネットワークがすでにオフラインになっていた場合、これは誤りです。ブラウザの [`navigator.onLine`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine) API を使ってそれをチェックすることはできますが、それを直接使うと、サーバで初期 HTML を生成する際には動作しません。要するに、このコードには改善の余地があるということです。

幸いなことに React 18 には、これらの問題をすべて解決してくれる専用の API である [`useSyncExternalStore`](/reference/react/useSyncExternalStore) が含まれています。以下は、この新しい API を活用して書き直された `useOnlineStatus` フックです。
React には、これらの問題をすべて解決してくれる専用の API である [`useSyncExternalStore`](/reference/react/useSyncExternalStore) が含まれています。以下は、この新しい API を活用して書き直された `useOnlineStatus` フックです。

<Sandpack>

Expand Down
9 changes: 9 additions & 0 deletions src/content/reference/react-dom/client/createRoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ React は `root` に `<App />` を表示し、その内部の DOM の管理を

* 同じルートに対して `render` を複数回呼び出すと、React は最新の JSX を反映するために必要なだけの DOM の更新を行います。React は、渡された JSX を以前にレンダーしたツリーと[「マッチング」](/learn/preserving-and-resetting-state)して、DOM のどの部分が再利用でき、どの部分を再作成する必要があるのかを決定します。同じルートに対して複数回 `render` を呼び出すことは、ルートコンポーネントで [`set` 関数](/reference/react/useState#setstate)を呼び出すことに似ており、React は不必要な DOM 更新を回避します。

* レンダーは一旦始まると同期的に行われますが、`root.render(...)` 自体はそうではありません。つまり `root.render()` の後のコードが、その特定のレンダー内のいずれかのエフェクト (`useLayoutEffect`, `useEffect`) よりも先に実行される可能性があるということです。これは通常問題なく、調整が必要になることは稀です。エフェクトのタイミングが重要となる稀なケースでは、初期レンダーが完全に同期的に実行されるように、`root.render(...)` を [`flushSync`](https://react.dev/reference/react-dom/client/flushSync) で囲むことができます。

```js
const root = createRoot(document.getElementById('root'));
root.render(<App />);
// 🚩 The HTML will not include the rendered <App /> yet:
console.log(document.body.innerHTML);
```

---

### `root.unmount()` {/*root-unmount*/}
Expand Down
5 changes: 2 additions & 3 deletions src/content/reference/react/Component.md
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ button { margin-left: 10px; }

エラーバウンダリコンポーネントを実装するためには、エラーに反応して state を更新し、ユーザにエラーメッセージを表示するための [`static getDerivedStateFromError`](#static-getderivedstatefromerror) を提供する必要があります。またオプションで、例えばエラーを分析サービスに記録するなどの追加のロジックを追加するために [`componentDidCatch`](#componentdidcatch) を実装することもできます。

<CanaryBadge /> [`captureOwnerStack`](/reference/react/captureOwnerStack) を使うことで開発中にオーナーのスタックトレースを含めることが可能です。
[`captureOwnerStack`](/reference/react/captureOwnerStack) を使うことで開発中にオーナーのスタックトレースを含めることが可能です。

```js {9-12,14-27}
import * as React from 'react';
Expand All @@ -1298,8 +1298,7 @@ class ErrorBoundary extends React.Component {
// in div (created by App)
// in App
info.componentStack,
// Only available in react@canary.
// Warning: Owner Stack is not available in production.
// Warning: `captureOwnerStack` is not available in production.
React.captureOwnerStack(),
);
}
Expand Down
8 changes: 7 additions & 1 deletion src/content/reference/react/StrictMode.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Strict Mode は開発中に以下のチェックを有効にします:

- コンポーネントは、純粋でない (impure) レンダーによって引き起こされるバグを見つけるために、[レンダーを追加で 1 回行います](#fixing-bugs-found-by-double-rendering-in-development)。
- コンポーネントは、エフェクトのクリーンアップし忘れによるバグを見つけるために、[エフェクトの実行を追加で 1 回行います](#fixing-bugs-found-by-re-running-effects-in-development)。
- コンポーネントは、ref のクリーンアップし忘れによるバグを見つけるために、[ref コールバックの実行を追加で 1 回行います](#fixing-bugs-found-by-cleaning-up-and-re-attaching-dom-refs-in-development)。
- コンポーネントは、ref のクリーンアップし忘れによるバグを見つけるために、[ref コールバックの実行を追加で 1 回行います](#fixing-bugs-found-by-re-running-ref-callbacks-in-development)。
- コンポーネントが[非推奨の API を使っていないかチェック](#fixing-deprecation-warnings-enabled-by-strict-mode)します。

**これらのチェックはすべて開発環境専用であり、本番用ビルドには影響しません。**
Expand Down Expand Up @@ -122,6 +122,12 @@ function App() {

上記の例では、Strict Mode のチェックは `Header` と `Footer` コンポーネントに対しては実行されません。しかし、`Sidebar` と `Content`、およびそれらの中にあるすべてのコンポーネントに対しては、どれだけ深いところにあってもチェックが実行されます。

<Note>

`StrictMode` がアプリの一部のみで有効になっている場合、React は本番環境で起こりえる動作のみを再現します。例えば、アプリのルートで `<StrictMode>` が有効になっていない場合、初期マウント時に[エフェクトを追加で再実行](#fixing-bugs-found-by-re-running-effects-in-development)することはなくなります。親エフェクトなしに子エフェクトが二重に発火することは本番環境では起こらないためです。

</Note>

---

### 開発中の二重レンダーによって見つかったバグの修正 {/*fixing-bugs-found-by-double-rendering-in-development*/}
Expand Down
Loading