Skip to content

Commit 3f72c96

Browse files
Merge pull request #426 from reactjs/sync-e85b71de
2 parents bcf760e + e79ca88 commit 3f72c96

10 files changed

+40
-30
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"next-remote-watch": "^1.0.0",
3737
"parse-numeric-range": "^1.2.0",
3838
"react": "^0.0.0-experimental-16d053d59-20230506",
39-
"react-collapsed": "npm:@gaearon/[email protected]",
39+
"react-collapsed": "4.0.4",
4040
"react-dom": "^0.0.0-experimental-16d053d59-20230506",
4141
"remark-frontmatter": "^4.0.1",
4242
"remark-gfm": "^3.0.1"

src/components/Layout/Sidebar/SidebarRouteTree.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {useRef, useLayoutEffect, Fragment} from 'react';
77
import cn from 'classnames';
88
import {useRouter} from 'next/router';
99
import {SidebarLink} from './SidebarLink';
10-
import useCollapse from 'react-collapsed';
10+
import {useCollapse} from 'react-collapsed';
1111
import usePendingRoute from 'hooks/usePendingRoute';
1212
import type {RouteItem} from 'components/Layout/getRouteMeta';
1313

src/components/Seo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const deployedTranslations = [
2222
'zh-hans',
2323
'es',
2424
'fr',
25+
'ja',
2526
// We'll add more languages when they have enough content.
2627
// Please DO NOT edit this list without a discussion in the reactjs/react.dev repo.
2728
// It must be the same between all translations.

src/content/learn/start-a-new-react-project.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ Expo 由 [Expo(公司)](https://expo.dev/about)維護。使用 Expo 構建
8989

9090
### Next.js (App Router) {/*nextjs-app-router*/}
9191

92-
**[Next.js 的 App Router](https://nextjs.org/docs) 是 Next.js API 的重新設計,旨在實現 React 團隊的全端架構願景。**它允許你在執行於伺服器上或甚至是構建期間的非同步(asynchronous component 中取得資料。
92+
**[Next.js 的 App Router](https://nextjs.org/docs) 是 Next.js API 的重新設計,旨在實現 React 團隊的全端架構願景。**它允許你在執行於伺服器上或甚至是構建期間的 asynchronous component 中取得資料。
9393

94-
Next.js 是由 [Vercel](https://vercel.com/) 維護。你可以將 [Next.js 應用程式部署](https://nextjs.org/docs/app/building-your-application/deploying)到任何 Node.js 或 serverless 主機,或是你自己的伺服器上。Next.js 還支援[靜態匯出](https://nextjs.org/docs/app/building-your-application/deploying/static-exports),不需要伺服器即可執行。
94+
Next.js 是由 [Vercel](https://vercel.com/) 維護。你可以將 [Next.js 應用程式部署](https://nextjs.org/docs/app/building-your-application/deploying)到任何 Node.js 或 serverless 主機,或是你自己的伺服器上。Next.js 還支援 [static export](https://nextjs.org/docs/app/building-your-application/deploying/static-exports),不需要伺服器即可執行。
9595

9696
<DeepDive>
9797

src/content/learn/typescript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export default App = AppTSX;
284284

285285
</Sandpack>
286286

287-
This technique works when you have an default value which makes sense - but there are occasionally cases when you do not, and in those cases `null` can feel reasonable as a default value. However, to allow the type-system to understand your code, you need to explicitly set `ContextShape | null` on the `createContext`.
287+
This technique works when you have a default value which makes sense - but there are occasionally cases when you do not, and in those cases `null` can feel reasonable as a default value. However, to allow the type-system to understand your code, you need to explicitly set `ContextShape | null` on the `createContext`.
288288

289289
This causes the issue that you need to eliminate the `| null` in the type for context consumers. Our recommendation is to have the hook do a runtime check for it's existence and throw an error when not present:
290290

@@ -460,4 +460,4 @@ We recommend the following resources:
460460

461461
- [React TypeScript Cheatsheet](https://react-typescript-cheatsheet.netlify.app/) is a community-maintained cheatsheet for using TypeScript with React, covering a lot of useful edge cases and providing more breadth than this document.
462462

463-
- [TypeScript Community Discord](https://discord.com/invite/typescript) is a great place to ask questions and get help with TypeScript and React issues.
463+
- [TypeScript Community Discord](https://discord.com/invite/typescript) is a great place to ask questions and get help with TypeScript and React issues.

src/content/reference/react/experimental_taintObjectReference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ experimental_taintObjectReference(
6868

6969
<Pitfall>
7070

71-
**Do not rely on just tainting for security.** Tainting an object doesn't prevent leaking of every possible derived value. For example, the clone of a tainted object will create a new untained object. Using data from a tainted object (e.g. `{secret: taintedObj.secret}`) will create a new value or object that is not tainted. Tainting is a layer of protection, a secure app will have multiple layers of protection, well designed APIs, and isolation patterns.
71+
**Do not rely on just tainting for security.** Tainting an object doesn't prevent leaking of every possible derived value. For example, the clone of a tainted object will create a new untained object. Using data from a tainted object (e.g. `{secret: taintedObj.secret}`) will create a new value or object that is not tainted. Tainting is a layer of protection; a secure app will have multiple layers of protection, well designed APIs, and isolation patterns.
7272

7373
</Pitfall>
7474

src/content/reference/react/experimental_taintUniqueValue.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ experimental_taintUniqueValue(
7575

7676
### Prevent a token from being passed to Client Components {/*prevent-a-token-from-being-passed-to-client-components*/}
7777

78-
To ensure that sensitive information such as passwords, session tokens, or other unique values do not inadvertently get passed to Client Components, the `taintUniqueValue` function provides a layer of protection. When a value is tainted, any attempt to pass it to a Client Component will result in an error.
78+
To ensure that sensitive information such as passwords, session tokens, or other unique values do not inadvertently get passed to Client Components, the `taintUniqueValue` function provides a layer of protection. When a value is tainted, any attempt to pass it to a Client Component will result in an error.
7979

8080
The `lifetime` argument defines the duration for which the value remains tainted. For values that should remain tainted indefinitely, objects like [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) or `process` can serve as the `lifetime` argument. These objects have a lifespan that spans the entire duration of your app's execution.
8181

@@ -130,7 +130,7 @@ In this example, the constant `password` is tainted. Then `password` is used to
130130

131131
Other similar ways of deriving new values from tainted values like concatenating it into a larger string, converting it to base64, or returning a substring create untained values.
132132

133-
Tainting only protects against simple mistakes like explictly passing secret values to the client. Mistakes in calling the `taintUniqueValue` like using a global store outside of React, without the corresponding lifetime object, can cause the tainted value to become untainted. Tainting is a layer of protection, a secure app will have multiple layers of protection, well designed APIs, and isolation patterns.
133+
Tainting only protects against simple mistakes like explictly passing secret values to the client. Mistakes in calling the `taintUniqueValue` like using a global store outside of React, without the corresponding lifetime object, can cause the tainted value to become untainted. Tainting is a layer of protection; a secure app will have multiple layers of protection, well designed APIs, and isolation patterns.
134134

135135
</Pitfall>
136136

@@ -176,7 +176,7 @@ export function fetchAPI(url) {
176176
}
177177
```
178178

179-
Sometimes mistakes happen during refactoring and not all of your colleagues might know about this.
179+
Sometimes mistakes happen during refactoring and not all of your colleagues might know about this.
180180
To protect against this mistakes happening down the line we can "taint" the actual password:
181181

182182
```js

src/content/reference/react/useSyncExternalStore.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ The current snapshot of the store which you can use in your rendering logic.
5757
5858
* If a different `subscribe` function is passed during a re-render, React will re-subscribe to the store using the newly passed `subscribe` function. You can prevent this by declaring `subscribe` outside the component.
5959
60+
* If the store is mutated during a [non-blocking transition update](/reference/react/useTransition), React will fall back to performing that update as blocking. Specifically, React will call `getSnapshot` a second time just before applying changes to the DOM. If it returns a different value than when it was called originally, React will restart the transition update from scratch, this time applying it as a blocking update, to ensure that every component on screen is reflecting the same version of the store.
61+
62+
* It's not recommended to _suspend_ a render based on a store value returned by `useSyncExternalStore`. The reason is that mutations to the external store cannot be [marked as non-blocking transition updates](/reference/react/useTransition), so they will trigger the nearest [`Suspense` fallback](/reference/react/Suspense), replacing already-rendered content on screen with a loading spinner, which typically makes a poor UX.
63+
64+
For example, the following are discouraged:
65+
66+
```js
67+
const LazyProductDetailPage = lazy(() => import('./ProductDetailPage.js'));
68+
69+
function ShoppingApp() {
70+
const selectedProductId = useSyncExternalStore(...);
71+
72+
// ❌ Calling `use` with a Promise dependent on `selectedProductId`
73+
const data = use(fetchItem(selectedProductId))
74+
75+
// ❌ Conditionally rendering a lazy component based on `selectedProductId`
76+
return selectedProductId != null ? <LazyProductDetailPage /> : <FeaturedProducts />;
77+
}
78+
```
79+
6080
---
6181
6282
## Usage {/*usage*/}
@@ -425,4 +445,4 @@ function ChatIndicator({ userId }) {
425445

426446
// ...
427447
}
428-
```
448+
```

src/sidebarReference.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,13 @@
130130
},
131131
{
132132
"title": "experimental_taintObjectReference",
133-
"path": "/reference/react/experimental_taintObjectReference"
133+
"path": "/reference/react/experimental_taintObjectReference",
134+
"canary": true
134135
},
135136
{
136137
"title": "experimental_taintUniqueValue",
137-
"path": "/reference/react/experimental_taintUniqueValue"
138+
"path": "/reference/react/experimental_taintUniqueValue",
139+
"canary": true
138140
}
139141
]
140142
},

yarn.lock

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4797,11 +4797,6 @@ path-type@^4.0.0:
47974797
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
47984798
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
47994799

4800-
performance-now@^2.1.0:
4801-
version "2.1.0"
4802-
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
4803-
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
4804-
48054800
periscopic@^3.0.0:
48064801
version "3.0.4"
48074802
resolved "https://registry.yarnpkg.com/periscopic/-/periscopic-3.0.4.tgz#b3fbed0d1bc844976b977173ca2cd4a0ef4fa8d1"
@@ -5284,13 +5279,6 @@ queue-microtask@^1.2.2:
52845279
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
52855280
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
52865281

5287-
raf@^3.4.1:
5288-
version "3.4.1"
5289-
resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39"
5290-
integrity sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==
5291-
dependencies:
5292-
performance-now "^2.1.0"
5293-
52945282
range-parser@~1.2.1:
52955283
version "1.2.1"
52965284
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
@@ -5306,12 +5294,11 @@ [email protected]:
53065294
iconv-lite "0.4.24"
53075295
unpipe "1.0.0"
53085296

5309-
"react-collapsed@npm:@gaearon/[email protected]":
5310-
version "3.1.0-forked.1"
5311-
resolved "https://registry.yarnpkg.com/@gaearon/react-collapsed/-/react-collapsed-3.1.0-forked.1.tgz#b287b81fc2af2971d7d7b523dc40b6cf116822ac"
5312-
integrity sha512-QkW55Upl4eeOtnDMOxasafDtDwaF+DpYKvHq8KZoNz9P477iUH8Ik1YFYuqtI7UA8mHm1/z66LD678dZCXwEEg==
5297+
react-collapsed@4.0.4:
5298+
version "4.0.4"
5299+
resolved "https://registry.yarnpkg.com/react-collapsed/-/react-collapsed-4.0.4.tgz#4c6bce3a15286d43e95b6730ad70ec387a54caa9"
5300+
integrity sha512-8avvmnQxDYTgGZYVP9+3Z7doomxVEBoCkukpTmUHEIrAYvELZ5jNNfYCt/hCpHB6GmQbzZoDmnDupjsnQVgcCQ==
53135301
dependencies:
5314-
raf "^3.4.1"
53155302
tiny-warning "^1.0.3"
53165303

53175304

0 commit comments

Comments
 (0)