Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/reactjs/react.dev into sync…
Browse files Browse the repository at this point in the history
…-5de85198
  • Loading branch information
react-translations-bot committed Mar 11, 2024
2 parents c3583ab + 5de8519 commit 939f2e7
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"check-all": "npm-run-all prettier lint:fix tsc"
},
"dependencies": {
"@codesandbox/sandpack-react": "2.13.1",
"@codesandbox/sandpack-react": "2.13.5",
"@docsearch/css": "3.0.0-alpha.41",
"@docsearch/react": "3.0.0-alpha.41",
"@headlessui/react": "^1.7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/content/community/team.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Current members of the React team are listed in alphabetical order below.
Andrey started his career as a designer and then gradually transitioned into web development. After joining the React Data team at Meta he worked on adding an incremental JavaScript compiler to Relay, and then later on, worked on removing the same compiler from Relay. Outside of work, Andrey likes to play music and engage in various sports.
</TeamMember>

<TeamMember name="Dan Abramov" permalink="dan-abramov" photo="/images/team/gaearon.jpg" github="gaearon" twitter="dan_abramov" title="Independent Engineer">
<TeamMember name="Dan Abramov" permalink="dan-abramov" photo="/images/team/gaearon.jpg" github="gaearon" twitter="dan_abramov2" title="Independent Engineer">
Dan got into programming after he accidentally discovered Visual Basic inside Microsoft PowerPoint. He has found his true calling in turning [Sebastian](#sebastian-markbåge)'s tweets into long-form blog posts. Dan occasionally wins at Fortnite by hiding in a bush until the game ends.
</TeamMember>

Expand Down
2 changes: 1 addition & 1 deletion src/content/learn/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TypeScript is a popular way to add type definitions to JavaScript codebases. Out

All [production-grade React frameworks](/learn/start-a-new-react-project#production-grade-react-frameworks) offer support for using TypeScript. Follow the framework specific guide for installation:

- [Next.js](https://nextjs.org/docs/pages/building-your-application/configuring/typescript)
- [Next.js](https://nextjs.org/docs/app/building-your-application/configuring/typescript)
- [Remix](https://remix.run/docs/en/1.19.2/guides/typescript)
- [Gatsby](https://www.gatsbyjs.com/docs/how-to/custom-configuration/typescript/)
- [Expo](https://docs.expo.dev/guides/typescript/)
Expand Down
8 changes: 4 additions & 4 deletions src/content/reference/react/useDeferredValue.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function SearchPage() {

#### Returns {/*returns*/}

During the initial render, the returned deferred value will be the same as the value you provided. During updates, React will first attempt a re-render with the old value (so it will return the old value), and then try another re-render in background with the new value (so it will return the updated value).
During the initial render, the returned deferred value will be the same as the value you provided. During updates, React will first attempt a re-render with the old value (so it will return the old value), and then try another re-render in the background with the new value (so it will return the updated value).

#### Caveats {/*caveats*/}

Expand Down Expand Up @@ -76,7 +76,7 @@ function SearchPage() {

During the initial render, the <CodeStep step={2}>deferred value</CodeStep> will be the same as the <CodeStep step={1}>value</CodeStep> you provided.

During updates, the <CodeStep step={2}>deferred value</CodeStep> will "lag behind" the latest <CodeStep step={1}>value</CodeStep>. In particular, React will first re-render *without* updating the deferred value, and then try to re-render with the newly received value in background.
During updates, the <CodeStep step={2}>deferred value</CodeStep> will "lag behind" the latest <CodeStep step={1}>value</CodeStep>. In particular, React will first re-render *without* updating the deferred value, and then try to re-render with the newly received value in the background.

**Let's walk through an example to see when this is useful.**

Expand Down Expand Up @@ -508,7 +508,7 @@ You can think of it as happening in two steps:

1. **First, React re-renders with the new `query` (`"ab"`) but with the old `deferredQuery` (still `"a")`.** The `deferredQuery` value, which you pass to the result list, is *deferred:* it "lags behind" the `query` value.

2. **In background, React tries to re-render with *both* `query` and `deferredQuery` updated to `"ab"`.** If this re-render completes, React will show it on the screen. However, if it suspends (the results for `"ab"` have not loaded yet), React will abandon this rendering attempt, and retry this re-render again after the data has loaded. The user will keep seeing the stale deferred value until the data is ready.
2. **In the background, React tries to re-render with *both* `query` and `deferredQuery` updated to `"ab"`.** If this re-render completes, React will show it on the screen. However, if it suspends (the results for `"ab"` have not loaded yet), React will abandon this rendering attempt, and retry this re-render again after the data has loaded. The user will keep seeing the stale deferred value until the data is ready.

The deferred "background" rendering is interruptible. For example, if you type into the input again, React will abandon it and restart with the new value. React will always use the latest provided value.

Expand Down Expand Up @@ -952,7 +952,7 @@ While these techniques are helpful in some cases, `useDeferredValue` is better s

Unlike debouncing or throttling, it doesn't require choosing any fixed delay. If the user's device is fast (e.g. powerful laptop), the deferred re-render would happen almost immediately and wouldn't be noticeable. If the user's device is slow, the list would "lag behind" the input proportionally to how slow the device is.

Also, unlike with debouncing or throttling, deferred re-renders done by `useDeferredValue` are interruptible by default. This means that if React is in the middle of re-rendering a large list, but the user makes another keystroke, React will abandon that re-render, handle the keystroke, and then start rendering in background again. By contrast, debouncing and throttling still produce a janky experience because they're *blocking:* they merely postpone the moment when rendering blocks the keystroke.
Also, unlike with debouncing or throttling, deferred re-renders done by `useDeferredValue` are interruptible by default. This means that if React is in the middle of re-rendering a large list, but the user makes another keystroke, React will abandon that re-render, handle the keystroke, and then start rendering in the background again. By contrast, debouncing and throttling still produce a janky experience because they're *blocking:* they merely postpone the moment when rendering blocks the keystroke.

If the work you're optimizing doesn't happen during rendering, debouncing and throttling are still useful. For example, they can let you fire fewer network requests. You can also use these techniques together.

Expand Down
4 changes: 4 additions & 0 deletions src/styles/sandpack.css
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,7 @@ html.dark .sp-devtools > div {
}
}
}

.sp-loading .sp-icon-standalone span {
display: none;
}
136 changes: 136 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,142 @@
"source": "/learn/meet-the-team",
"destination": "/community/team",
"permanent": true
},
{
"source": "/link/warning-keys",
"destination": "/learn/rendering-lists#keeping-list-items-in-order-with-key",
"permanent": false
},

{
"source": "/link/invalid-hook-call",
"destination": "/warnings/invalid-hook-call-warning",
"permanent": false
},
{
"source": "/link/hooks-data-fetching",
"destination": "/reference/react/useEffect#fetching-data-with-effects",
"permanent": false
},
{
"source": "/link/special-props",
"destination": "/warnings/special-props",
"permanent": false
},
{
"source": "/link/dangerously-set-inner-html",
"destination": "/reference/react-dom/components/common#dangerously-setting-the-inner-html",
"permanent": false
},
{
"source": "/link/controlled-components",
"destination": "/reference/react-dom/components/input#controlling-an-input-with-a-state-variable",
"permanent": false
},
{
"source": "/link/react-devtools",
"destination": "/learn/react-developer-tools",
"permanent": false
},
{
"source": "/link/invalid-aria-props",
"destination": "/warnings/invalid-aria-prop",
"permanent": false
},
{
"source": "/link/hydration-mismatch",
"destination": "/reference/react-dom/client/hydrateRoot#hydrating-server-rendered-html",
"permanent": false
},
{
"source": "/link/switch-to-createroot",
"destination": "/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis",
"permanent": false
},
{
"source": "/link/error-boundaries",
"destination": "/reference/react/Component#catching-rendering-errors-with-an-error-boundary",
"permanent": false
},
{
"source": "/link/strict-mode-find-node",
"destination": "/reference/react-dom/findDOMNode#alternatives",
"permanent": false
},
{
"source": "/link/rules-of-hooks",
"destination": "/warnings/invalid-hook-call-warning",
"permanent": false
},
{
"source": "/link/event-pooling",
"destination": "https://legacy.reactjs.org/docs/legacy-event-pooling.html",
"permanent": false
},
{
"source": "/link/legacy-context",
"destination": "https://legacy.reactjs.org/docs/legacy-context.html",
"permanent": false
},
{
"source": "/link/crossorigin-error",
"destination": "https://legacy.reactjs.org/docs/cross-origin-errors.html",
"permanent": false
},
{
"source": "/link/react-polyfills",
"destination": "https://legacy.reactjs.org/docs/javascript-environment-requirements.html",
"permanent": false
},
{
"source": "/link/wrap-tests-with-act",
"destination": "https://legacy.reactjs.org/docs/test-utils.html#act",
"permanent": false
},
{
"source": "/link/refs-must-have-owner",
"destination": "https://legacy.reactjs.org/warnings/refs-must-have-owner.html",
"permanent": false
},
{
"source": "/link/derived-state",
"destination": "https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html",
"permanent": false
},
{
"source": "/link/strict-mode-string-ref",
"destination": "https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs",
"permanent": false
},
{
"source": "/link/perf-use-production-build",
"destination": "https://legacy.reactjs.org/docs/optimizing-performance.html#use-the-production-build",
"permanent": false
},
{
"source": "/link/unsafe-component-lifecycles",
"destination": "https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html",
"permanent": false
},
{
"source": "/link/test-utils-mock-component",
"destination": "https://gist.github.com/bvaughn/fbf41b3f895bf2d297935faa5525eee9",
"permanent": false
},
{
"source": "/link/attribute-behavior",
"destination": "https://legacy.reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html#changes-in-detail",
"permanent": false
},
{
"source": "/link/react-devtools-faq",
"destination": "https://github.com/facebook/react/tree/main/packages/react-devtools#faq",
"permanent": false
},
{
"source": "/link/setstate-in-render",
"destination": "https://github.com/facebook/react/issues/18178#issuecomment-595846312",
"permanent": false
}
],
"headers": [
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -619,21 +619,21 @@
outvariant "^1.4.0"
strict-event-emitter "^0.4.3"

"@codesandbox/sandpack-client@^2.13.0":
version "2.13.0"
resolved "https://registry.yarnpkg.com/@codesandbox/sandpack-client/-/sandpack-client-2.13.0.tgz#c4e12628a3aceb4a2c99c501bea691b4276eab27"
integrity sha512-1rOLj9wkbBd3RV6/zRq+IV52egy22RQMKDTtdR+lQzy87uj0tlbYjAwtUZSjkioHlj6U8Y82uWLf71nvFIxE0g==
"@codesandbox/sandpack-client@^2.13.2":
version "2.13.2"
resolved "https://registry.yarnpkg.com/@codesandbox/sandpack-client/-/sandpack-client-2.13.2.tgz#8e573e96d341d3284ce579a71c6c57f16aefc80e"
integrity sha512-uAuxQOF7p8y4m7H0ojedDcWRf62xVK7UIYIJoX5LkhcV0SW1BTXcRkVNuR0/MSCSv+Og1dBeV8+Xpye9PX0quA==
dependencies:
"@codesandbox/nodebox" "0.1.8"
buffer "^6.0.3"
dequal "^2.0.2"
outvariant "1.4.0"
static-browser-server "1.0.3"

"@codesandbox/[email protected].1":
version "2.13.1"
resolved "https://registry.yarnpkg.com/@codesandbox/sandpack-react/-/sandpack-react-2.13.1.tgz#ba69a227d0c5157bb48685a02fefc0baa83bdc09"
integrity sha512-R8oGO4QHHWTyA7r6NWHtBakizgX+rl/Rc6cbQunXGNm4vV/lqqU4NS+MVp2rXA+c8DifOLi1wA2wUZUN//Z9bw==
"@codesandbox/[email protected].5":
version "2.13.5"
resolved "https://registry.yarnpkg.com/@codesandbox/sandpack-react/-/sandpack-react-2.13.5.tgz#bc4b3fe43b74fdb011f69d3d9a117415110c709e"
integrity sha512-MWzh2P/Asck0JSCKY3y7WecdUBBEqB0NFi4p+ohoZMTYqHWTaYfd7nbPlNmGIE1xcGppSZEqPVDjOpAfeQ0zFw==
dependencies:
"@codemirror/autocomplete" "^6.4.0"
"@codemirror/commands" "^6.1.3"
Expand All @@ -643,7 +643,7 @@
"@codemirror/language" "^6.3.2"
"@codemirror/state" "^6.2.0"
"@codemirror/view" "^6.7.1"
"@codesandbox/sandpack-client" "^2.13.0"
"@codesandbox/sandpack-client" "^2.13.2"
"@lezer/highlight" "^1.1.3"
"@react-hook/intersection-observer" "^3.1.1"
"@stitches/core" "^1.2.6"
Expand Down

0 comments on commit 939f2e7

Please sign in to comment.