You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/build-a-react-app-from-scratch.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ Rsbuild includes built-in support for React features like fast refresh, JSX, Typ
65
65
66
66
#### Metro for React Native {/*react-native*/}
67
67
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.
69
69
70
70
</Note>
71
71
@@ -83,7 +83,7 @@ Routers are a core part of modern applications, and are usually integrated with
Copy file name to clipboardExpand all lines: src/content/learn/reusing-logic-with-custom-hooks.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1333,7 +1333,7 @@ export function useOnlineStatus() {
1333
1333
1334
1334
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.
1335
1335
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:
Copy file name to clipboardExpand all lines: src/content/learn/tutorial-tic-tac-toe.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2247,7 +2247,7 @@ body {
2247
2247
2248
2248
</Sandpack>
2249
2249
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.)
2251
2251
2252
2252
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).
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/client/createRoot.md
+9
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,15 @@ React will display `<App />` in the `root`, and take over managing the DOM insid
90
90
91
91
* If you call `render` on the same root more than once, React will update the DOM as necessary to reflect the latest JSX you passed. React will decide which parts of the DOM can be reused and which need to be recreated by ["matching it up"](/learn/preserving-and-resetting-state) with the previously rendered tree. Calling `render` on the same root again is similar to calling the [`set` function](/reference/react/useState#setstate) on the root component: React avoids unnecessary DOM updates.
92
92
93
+
* Although rendering is synchronous once it starts, `root.render(...)` is not. This means code after `root.render()` may run before any effects (`useLayoutEffect`, `useEffect`) of that specific render are fired. This is usually fine and rarely needs adjustment. In rare cases where effect timing matters, you can wrap `root.render(...)` in [`flushSync`](https://react.dev/reference/react-dom/client/flushSync) to ensure the initial render runs fully synchronously.
Copy file name to clipboardExpand all lines: src/content/reference/react/Component.md
+2-3
Original file line number
Diff line number
Diff line change
@@ -1273,7 +1273,7 @@ By default, if your application throws an error during rendering, React will rem
1273
1273
1274
1274
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.
1275
1275
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.
1277
1277
1278
1278
```js {9-12,14-27}
1279
1279
import*asReactfrom'react';
@@ -1298,8 +1298,7 @@ class ErrorBoundary extends React.Component {
1298
1298
// in div (created by App)
1299
1299
// in App
1300
1300
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.
Copy file name to clipboardExpand all lines: src/content/reference/react/StrictMode.md
+7-1
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ Strict Mode enables the following checks in development:
88
88
89
89
- Your components will [re-render an extra time](#fixing-bugs-found-by-double-rendering-in-development) to find bugs caused by impure rendering.
90
90
- 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.
92
92
- Your components will [be checked for usage of deprecated APIs.](#fixing-deprecation-warnings-enabled-by-strict-mode)
93
93
94
94
**All of these checks are development-only and do not impact the production build.**
@@ -122,6 +122,12 @@ function App() {
122
122
123
123
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.
124
124
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
+
125
131
---
126
132
127
133
### Fixing bugs found by double rendering in development {/*fixing-bugs-found-by-double-rendering-in-development*/}
Copy file name to clipboardExpand all lines: src/content/reference/react/captureOwnerStack.md
-54
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,6 @@
2
2
title: captureOwnerStack
3
3
---
4
4
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
-
11
5
<Intro>
12
6
13
7
`captureOwnerStack` reads the current Owner Stack in development and returns it as a string if available.
0 commit comments