Skip to content

Commit 7cb4e3b

Browse files
Merge branch 'main' of https://github.com/reactjs/react.dev into sync-5138e605
2 parents 7b3a8fd + 5138e60 commit 7cb4e3b

18 files changed

+63
-104
lines changed

postcss.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ module.exports = {
1717
},
1818
},
1919
},
20-
}
20+
};

public/js/jsfiddle-integration-babel.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
// Do not delete or move this file.
66
// Many fiddles reference it so we have to keep it here.
7-
(function() {
7+
(function () {
88
var tag = document.querySelector(
99
'script[type="application/javascript;version=1.7"]'
1010
);
1111
if (!tag || tag.textContent.indexOf('window.onload=function(){') !== -1) {
12-
alert('Bad JSFiddle configuration, please fork the original React JSFiddle');
12+
alert(
13+
'Bad JSFiddle configuration, please fork the original React JSFiddle'
14+
);
1315
}
1416
tag.setAttribute('type', 'text/babel');
1517
tag.textContent = tag.textContent.replace(/^\/\/<!\[CDATA\[/, '');

public/js/jsfiddle-integration.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
// Do not delete or move this file.
66
// Many fiddles reference it so we have to keep it here.
7-
(function() {
7+
(function () {
88
var tag = document.querySelector(
99
'script[type="application/javascript;version=1.7"]'
1010
);
1111
if (!tag || tag.textContent.indexOf('window.onload=function(){') !== -1) {
12-
alert('Bad JSFiddle configuration, please fork the original React JSFiddle');
12+
alert(
13+
'Bad JSFiddle configuration, please fork the original React JSFiddle'
14+
);
1315
}
1416
tag.setAttribute('type', 'text/jsx;harmony=true');
1517
tag.textContent = tag.textContent.replace(/^\/\/<!\[CDATA\[/, '');

scripts/headingIDHelpers/walk.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ const fs = require('fs');
22

33
module.exports = function walk(dir) {
44
let results = [];
5-
/**
5+
/**
66
* If the param is a directory we can return the file
77
*/
8-
if(dir.includes('md')){
8+
if (dir.includes('md')) {
99
return [dir];
1010
}
1111
const list = fs.readdirSync(dir);

scripts/headingIdLinter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const validateHeaderIds = require('./headingIDHelpers/validateHeadingIDs');
22
const generateHeadingIds = require('./headingIDHelpers/generateHeadingIDs');
33

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

1111
const markdownPaths = process.argv.slice(2);
1212
if (markdownPaths.includes('--fix')) {

src/components/MDX/ErrorDecoder.tsx

+17-12
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function parseQueryString(search: string): Array<string | undefined> {
6969
}
7070

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

86-
setMessage(
87-
urlify(
88-
replaceArgs(
89-
errorMessage,
90-
parseQueryString(window.location.search),
91-
'[missing argument]'
92-
)
93-
)
94-
);
91+
// Before React 19.1, the error message didn't have an arg, and was always HTML.
92+
if (args.length === 0) {
93+
args.push('HTML');
94+
} else if (args.length === 1 && args[0] === '') {
95+
args[0] = 'HTML';
96+
}
97+
}
98+
99+
setMessage(urlify(replaceArgs(message, args, '[missing argument]')));
95100
setIsReady(true);
96-
}, [hasParams, errorMessage]);
101+
}, [errorCode, hasParams, errorMessage]);
97102

98103
return (
99104
<code
100105
className={cn(
101-
'block bg-red-100 text-red-600 py-4 px-6 mt-5 rounded-lg',
106+
'whitespace-pre-line block bg-red-100 text-red-600 py-4 px-6 mt-5 rounded-lg',
102107
isReady ? 'opacity-100' : 'opacity-0'
103108
)}>
104109
<b>{message}</b>

src/components/MDX/Sandpack/template.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ root.render(
2828
eject: 'react-scripts eject',
2929
},
3030
dependencies: {
31-
react: '19.0.0-rc-3edc000d-20240926',
32-
'react-dom': '19.0.0-rc-3edc000d-20240926',
31+
react: '^19.1.0',
32+
'react-dom': '^19.1.0',
3333
'react-scripts': '^5.0.0',
3434
},
3535
},

src/content/community/meetups.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
8181
* [Thessaloniki](https://www.meetup.com/Thessaloniki-ReactJS-Meetup/)
8282

8383
## India {/*india*/}
84-
* [Ahmedabad](https://www.meetup.com/react-ahmedabad/)
84+
* [Ahmedabad](https://reactahmedabad.dev/)
8585
* [Bangalore (React)](https://www.meetup.com/ReactJS-Bangalore/)
8686
* [Bangalore (React Native)](https://www.meetup.com/React-Native-Bangalore-Meetup)
8787
* [Chennai](https://www.linkedin.com/company/chennaireact)
@@ -169,6 +169,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
169169
* [Cleveland, OH - ReactJS](https://www.meetup.com/Cleveland-React/)
170170
* [Columbus, OH - ReactJS](https://www.meetup.com/ReactJS-Columbus-meetup/)
171171
* [Dallas, TX - ReactJS](https://www.meetup.com/ReactDallas/)
172+
* [Denver, CO - React Denver](https://reactdenver.com/)
172173
* [Detroit, MI - Detroit React User Group](https://www.meetup.com/Detroit-React-User-Group/)
173174
* [Indianapolis, IN - React.Indy](https://www.meetup.com/React-Indy)
174175
* [Irvine, CA - ReactJS](https://www.meetup.com/ReactJS-OC/)

src/content/learn/build-a-react-app-from-scratch.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Rsbuild includes built-in support for React features like fast refresh, JSX, Typ
6565

6666
#### Metro for React Native {/*react-native*/}
6767

68-
If you'd you're starting from scratch with React Native you'll need to use [Metro](https://metrobundler.dev/), the JavaScript bundler for React Native. Metro supports bundling for platforms like iOS and Android, but lacks many features when compared to the tools here. We recommend starting with Vite, Parcel, or Rsbuild unless your project requires React Native support.
68+
If you're starting from scratch with React Native you'll need to use [Metro](https://metrobundler.dev/), the JavaScript bundler for React Native. Metro supports bundling for platforms like iOS and Android, but lacks many features when compared to the tools here. We recommend starting with Vite, Parcel, or Rsbuild unless your project requires React Native support.
6969

7070
</Note>
7171

@@ -83,7 +83,7 @@ Routers are a core part of modern applications, and are usually integrated with
8383

8484
We suggest using:
8585

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

8989

src/content/learn/reusing-logic-with-custom-hooks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ export function useOnlineStatus() {
13331333
13341334
In the above example, `useOnlineStatus` is implemented with a pair of [`useState`](/reference/react/useState) and [`useEffect`.](/reference/react/useEffect) However, this isn't the best possible solution. There is a number of edge cases it doesn't consider. For example, it assumes that when the component mounts, `isOnline` is already `true`, but this may be wrong if the network already went offline. You can use the browser [`navigator.onLine`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine) API to check for that, but using it directly would not work on the server for generating the initial HTML. In short, this code could be improved.
13351335
1336-
Luckily, React 18 includes a dedicated API called [`useSyncExternalStore`](/reference/react/useSyncExternalStore) which takes care of all of these problems for you. Here is how your `useOnlineStatus` Hook, rewritten to take advantage of this new API:
1336+
React includes a dedicated API called [`useSyncExternalStore`](/reference/react/useSyncExternalStore) which takes care of all of these problems for you. Here is your `useOnlineStatus` Hook, rewritten to take advantage of this new API:
13371337
13381338
<Sandpack>
13391339

src/content/learn/tutorial-tic-tac-toe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,7 @@ body {
22472247
22482248
</Sandpack>
22492249
2250-
As you iterate through `history` array inside the function you passed to `map`, the `squares` argument goes through each element of `history`, and the `move` argument goes through each array index: `0`, `1`, `2`, …. (In most cases, you'd need the actual array elements, but to render a list of moves you will only need indexes.)
2250+
As you iterate through the `history` array inside the function you passed to `map`, the `squares` argument goes through each element of `history`, and the `move` argument goes through each array index: `0`, `1`, `2`, …. (In most cases, you'd need the actual array elements, but to render a list of moves you will only need indexes.)
22512251
22522252
For each move in the tic-tac-toe game's history, you create a list item `<li>` which contains a button `<button>`. The button has an `onClick` handler which calls a function called `jumpTo` (that you haven't implemented yet).
22532253

src/content/reference/react/Component.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ By default, if your application throws an error during rendering, React will rem
12731273
12741274
To implement an error boundary component, you need to provide [`static getDerivedStateFromError`](#static-getderivedstatefromerror) which lets you update state in response to an error and display an error message to the user. You can also optionally implement [`componentDidCatch`](#componentdidcatch) to add some extra logic, for example, to log the error to an analytics service.
12751275
1276-
<CanaryBadge /> With [`captureOwnerStack`](/reference/react/captureOwnerStack) you can include the Owner Stack during development.
1276+
With [`captureOwnerStack`](/reference/react/captureOwnerStack) you can include the Owner Stack during development.
12771277
12781278
```js {9-12,14-27}
12791279
import * as React from 'react';
@@ -1298,8 +1298,7 @@ class ErrorBoundary extends React.Component {
12981298
// in div (created by App)
12991299
// in App
13001300
info.componentStack,
1301-
// Only available in react@canary.
1302-
// Warning: Owner Stack is not available in production.
1301+
// Warning: `captureOwnerStack` is not available in production.
13031302
React.captureOwnerStack(),
13041303
);
13051304
}

src/content/reference/react/StrictMode.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Strict Mode enables the following checks in development:
8888

8989
- Your components will [re-render an extra time](#fixing-bugs-found-by-double-rendering-in-development) to find bugs caused by impure rendering.
9090
- Your components will [re-run Effects an extra time](#fixing-bugs-found-by-re-running-effects-in-development) to find bugs caused by missing Effect cleanup.
91-
- Your components will [re-run ref callbacks an extra time](#fixing-bugs-found-by-cleaning-up-and-re-attaching-dom-refs-in-development) to find bugs caused by missing ref cleanup.
91+
- Your components will [re-run ref callbacks an extra time](#fixing-bugs-found-by-re-running-ref-callbacks-in-development) to find bugs caused by missing ref cleanup.
9292
- Your components will [be checked for usage of deprecated APIs.](#fixing-deprecation-warnings-enabled-by-strict-mode)
9393

9494
**All of these checks are development-only and do not impact the production build.**
@@ -122,6 +122,12 @@ function App() {
122122

123123
In this example, Strict Mode checks will not run against the `Header` and `Footer` components. However, they will run on `Sidebar` and `Content`, as well as all of the components inside them, no matter how deep.
124124

125+
<Note>
126+
127+
When `StrictMode` is enabled for a part of the app, React will only enable behaviors that are possible in production. For example, if `<StrictMode>` is not enabled at the root of the app, it will not [re-run Effects an extra time](#fixing-bugs-found-by-re-running-effects-in-development) on initial mount, since this would cause child effects to double fire without the parent effects, which cannot happen in production.
128+
129+
</Note>
130+
125131
---
126132

127133
### Fixing bugs found by double rendering in development {/*fixing-bugs-found-by-double-rendering-in-development*/}

src/content/reference/react/captureOwnerStack.md

-54
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
title: captureOwnerStack
33
---
44

5-
<Canary>
6-
7-
The `captureOwnerStack` API is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
8-
9-
</Canary>
10-
115
<Intro>
126

137
`captureOwnerStack` reads the current Owner Stack in development and returns it as a string if available.
@@ -126,22 +120,6 @@ createRoot(document.createElement('div'), {
126120
);
127121
```
128122

129-
```json package.json hidden
130-
{
131-
"dependencies": {
132-
"react": "canary",
133-
"react-dom": "canary",
134-
"react-scripts": "latest"
135-
},
136-
"scripts": {
137-
"start": "react-scripts start",
138-
"build": "react-scripts build",
139-
"test": "react-scripts test --env=jsdom",
140-
"eject": "react-scripts eject"
141-
}
142-
}
143-
```
144-
145123
```html public/index.html hidden
146124
<!DOCTYPE html>
147125
<html lang="en">
@@ -357,22 +335,6 @@ const container = document.getElementById("root");
357335
createRoot(container).render(<App />);
358336
```
359337

360-
```json package.json hidden
361-
{
362-
"dependencies": {
363-
"react": "canary",
364-
"react-dom": "canary",
365-
"react-scripts": "latest"
366-
},
367-
"scripts": {
368-
"start": "react-scripts start",
369-
"build": "react-scripts build",
370-
"test": "react-scripts test --env=jsdom",
371-
"eject": "react-scripts eject"
372-
}
373-
}
374-
```
375-
376338
```js src/App.js
377339
function Component() {
378340
return <button onClick={() => console.error('Some console error')}>Trigger console.error()</button>;
@@ -417,22 +379,6 @@ export default function App() {
417379
}
418380
```
419381

420-
```json package.json hidden
421-
{
422-
"dependencies": {
423-
"react": "canary",
424-
"react-dom": "canary",
425-
"react-scripts": "latest"
426-
},
427-
"scripts": {
428-
"start": "react-scripts start",
429-
"build": "react-scripts build",
430-
"test": "react-scripts test --env=jsdom",
431-
"eject": "react-scripts eject"
432-
}
433-
}
434-
```
435-
436382
</Sandpack>
437383

438384
### `captureOwnerStack` is not available {/*captureownerstack-is-not-available*/}

src/content/reference/react/useSyncExternalStore.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -405,43 +405,43 @@ If your store data is mutable, your `getSnapshot` function should return an immu
405405
406406
This `subscribe` function is defined *inside* a component so it is different on every re-render:
407407
408-
```js {4-7}
408+
```js {2-5}
409409
function ChatIndicator() {
410-
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
411-
412410
// 🚩 Always a different function, so React will resubscribe on every re-render
413411
function subscribe() {
414412
// ...
415413
}
414+
415+
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
416416

417417
// ...
418418
}
419419
```
420420
421421
React will resubscribe to your store if you pass a different `subscribe` function between re-renders. If this causes performance issues and you'd like to avoid resubscribing, move the `subscribe` function outside:
422422
423-
```js {6-9}
424-
function ChatIndicator() {
425-
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
423+
```js {1-4}
424+
// ✅ Always the same function, so React won't need to resubscribe
425+
function subscribe() {
426426
// ...
427427
}
428428

429-
// ✅ Always the same function, so React won't need to resubscribe
430-
function subscribe() {
429+
function ChatIndicator() {
430+
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
431431
// ...
432432
}
433433
```
434434
435435
Alternatively, wrap `subscribe` into [`useCallback`](/reference/react/useCallback) to only resubscribe when some argument changes:
436436
437-
```js {4-8}
437+
```js {2-5}
438438
function ChatIndicator({ userId }) {
439-
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
440-
441439
// ✅ Same function as long as userId doesn't change
442440
const subscribe = useCallback(() => {
443441
// ...
444442
}, [userId]);
443+
444+
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
445445

446446
// ...
447447
}

src/pages/errors/[errorCode].tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function ErrorDecoderPage({
3636
}}
3737
routeTree={sidebarLearn as RouteItem}
3838
section="unknown">
39-
<div className="whitespace-pre-line">{parsedContent}</div>
39+
<div>{parsedContent}</div>
4040
{/* <MaxWidth>
4141
<P>
4242
We highly recommend using the development build locally when debugging

src/sidebarReference.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
{
118118
"title": "cache",
119119
"path": "/reference/react/cache"
120+
}, {
121+
"title": "captureOwnerStack",
122+
"path": "/reference/react/captureOwnerStack"
120123
},
121124
{
122125
"title": "createContext",
@@ -147,11 +150,6 @@
147150
"title": "experimental_taintUniqueValue",
148151
"path": "/reference/react/experimental_taintUniqueValue",
149152
"version": "canary"
150-
},
151-
{
152-
"title": "captureOwnerStack",
153-
"path": "/reference/react/captureOwnerStack",
154-
"version": "canary"
155153
}
156154
]
157155
},

src/siteConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) Facebook, Inc. and its affiliates.
33
*/
44
exports.siteConfig = {
5-
version: '19',
5+
version: '19.1',
66
// --------------------------------------
77
// Translations should replace these lines:
88
languageCode: 'en',

0 commit comments

Comments
 (0)