Skip to content

Commit d71fdec

Browse files
authored
Merge pull request #645 from reactjs/sync-e07ac94b
Sync with react.dev @ e07ac94
2 parents f91fa67 + 0eff222 commit d71fdec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2564
-69
lines changed

scripts/deadLinkChecker.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const PUBLIC_DIR = path.join(__dirname, '../public');
1010
const fileCache = new Map();
1111
const anchorMap = new Map(); // Map<filepath, Set<anchorId>>
1212
const contributorMap = new Map(); // Map<anchorId, URL>
13+
const redirectMap = new Map(); // Map<source, destination>
1314
let errorCodes = new Set();
1415

1516
async function readFileWithCache(filePath) {
@@ -162,6 +163,22 @@ async function validateLink(link) {
162163
return {valid: true};
163164
}
164165

166+
// Check for redirects
167+
if (redirectMap.has(urlWithoutAnchor)) {
168+
const redirectDestination = redirectMap.get(urlWithoutAnchor);
169+
if (
170+
redirectDestination.startsWith('http://') ||
171+
redirectDestination.startsWith('https://')
172+
) {
173+
return {valid: true};
174+
}
175+
const redirectedLink = {
176+
...link,
177+
url: redirectDestination + (anchorMatch ? anchorMatch[0] : ''),
178+
};
179+
return validateLink(redirectedLink);
180+
}
181+
165182
// Check if it's an error code link
166183
const errorCodeMatch = urlWithoutAnchor.match(/^\/errors\/(\d+)$/);
167184
if (errorCodeMatch) {
@@ -295,17 +312,42 @@ async function fetchErrorCodes() {
295312
}
296313
const codes = await response.json();
297314
errorCodes = new Set(Object.keys(codes));
298-
console.log(chalk.gray(`Fetched ${errorCodes.size} React error codes\n`));
315+
console.log(chalk.gray(`Fetched ${errorCodes.size} React error codes`));
299316
} catch (error) {
300317
throw new Error(`Failed to fetch error codes: ${error.message}`);
301318
}
302319
}
303320

321+
async function buildRedirectsMap() {
322+
try {
323+
const vercelConfigPath = path.join(__dirname, '../vercel.json');
324+
const vercelConfig = JSON.parse(
325+
await fs.promises.readFile(vercelConfigPath, 'utf8')
326+
);
327+
328+
if (vercelConfig.redirects) {
329+
for (const redirect of vercelConfig.redirects) {
330+
redirectMap.set(redirect.source, redirect.destination);
331+
}
332+
console.log(
333+
chalk.gray(`Loaded ${redirectMap.size} redirects from vercel.json`)
334+
);
335+
}
336+
} catch (error) {
337+
console.log(
338+
chalk.yellow(
339+
`Warning: Could not load redirects from vercel.json: ${error.message}\n`
340+
)
341+
);
342+
}
343+
}
344+
304345
async function main() {
305346
const files = getMarkdownFiles();
306347
console.log(chalk.gray(`Checking ${files.length} markdown files...`));
307348

308349
await fetchErrorCodes();
350+
await buildRedirectsMap();
309351
await buildContributorMap();
310352
await buildAnchorMap(files);
311353

@@ -315,6 +357,7 @@ async function main() {
315357
const totalLinks = results.reduce((sum, r) => sum + r.totalLinks, 0);
316358

317359
if (deadLinks.length > 0) {
360+
console.log('\n');
318361
for (const link of deadLinks) {
319362
console.log(chalk.yellow(`${link.file}:${link.line}:${link.column}`));
320363
console.log(chalk.reset(` Link text: ${link.text}`));

src/content/blog/2023/03/16/introducing-react-dev.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ When we released React Hooks in 2018, the Hooks docs assumed the reader is famil
4242
**The new docs teach React with Hooks from the beginning.** The docs are divided in two main sections:
4343

4444
* **[Learn React](/learn)** is a self-paced course that teaches React from scratch.
45-
* **[API Reference](/reference/react)** provides the details and usage examples for every React API.
45+
* **[API Reference](/reference)** provides the details and usage examples for every React API.
4646

4747
Let's have a closer look at what you can find in each section.
4848

@@ -607,7 +607,7 @@ button { display: block; margin-top: 10px; }
607607

608608
</Recipes>
609609

610-
Some API pages also include [Troubleshooting](/reference/react/useEffect#troubleshooting) (for common problems) and [Alternatives](https://18.react.dev/reference/react-dom/findDOMNode#alternatives) (for deprecated APIs).
610+
Some API pages also include [Troubleshooting](/reference/react/useEffect#troubleshooting) (for common problems) and [Alternatives](/reference/react-dom/findDOMNode#alternatives) (for deprecated APIs).
611611

612612
We hope that this approach will make the API reference useful not only as a way to look up an argument, but as a way to see all the different things you can do with any given API—and how it connects to the other ones.
613613

src/content/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The biggest change is that we introduced [`async` / `await`](https://github.com/
3131

3232
Now that we have data fetching pretty well sorted, we're exploring the other direction: sending data from the client to the server, so that you can execute database mutations and implement forms. We're doing this by letting you pass Server Action functions across the server/client boundary, which the client can then call, providing seamless RPC. Server Actions also give you progressively enhanced forms before JavaScript loads.
3333

34-
React Server Components has shipped in [Next.js App Router](/learn/creating-a-react-app#nextjs-app-router). This showcases a deep integration of a router that really buys into RSC as a primitive, but it's not the only way to build a RSC-compatible router and framework. There's a clear separation for features provided by the RSC spec and implementation. React Server Components is meant as a spec for components that work across compatible React frameworks.
34+
React Server Components has shipped in [Next.js App Router](/learn/start-a-new-react-project#nextjs-app-router). This showcases a deep integration of a router that really buys into RSC as a primitive, but it's not the only way to build a RSC-compatible router and framework. There's a clear separation for features provided by the RSC spec and implementation. React Server Components is meant as a spec for components that work across compatible React frameworks.
3535

3636
We generally recommend using an existing framework, but if you need to build your own custom framework, it is possible. Building your own RSC-compatible framework is not as easy as we'd like it to be, mainly due to the deep bundler integration needed. The current generation of bundlers are great for use on the client, but they weren't designed with first-class support for splitting a single module graph between the server and the client. This is why we're now partnering directly with bundler developers to get the primitives for RSC built-in.
3737

@@ -92,7 +92,7 @@ Since our last update, we've tested an experimental version of prerendering inte
9292

9393
## Transition Tracing {/*transition-tracing*/}
9494

95-
The Transition Tracing API lets you detect when [React Transitions](/reference/react/useTransition) become slower and investigate why they may be slow. Following our last update, we have completed the initial design of the API and published an [RFC](https://github.com/reactjs/rfcs/pull/238). The basic capabilities have also been implemented. The project is currently on hold. We welcome feedback on the RFC and look forward to resuming its development to provide a better performance measurement tool for React. This will be particularly useful with routers built on top of React Transitions, like the [Next.js App Router](/learn/creating-a-react-app#nextjs-app-router).
95+
The Transition Tracing API lets you detect when [React Transitions](/reference/react/useTransition) become slower and investigate why they may be slow. Following our last update, we have completed the initial design of the API and published an [RFC](https://github.com/reactjs/rfcs/pull/238). The basic capabilities have also been implemented. The project is currently on hold. We welcome feedback on the RFC and look forward to resuming its development to provide a better performance measurement tool for React. This will be particularly useful with routers built on top of React Transitions, like the [Next.js App Router](/learn/start-a-new-react-project#nextjs-app-router).
9696

9797
* * *
9898
In addition to this update, our team has made recent guest appearances on community podcasts and livestreams to speak more on our work and answer questions.

src/content/blog/2024/04/25/react-19-upgrade-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ For a list of all available codemods, see the [`react-codemod` repo](https://git
129129

130130
In previous versions of React, errors thrown during render were caught and rethrown. In DEV, we would also log to `console.error`, resulting in duplicate error logs.
131131

132-
In React 19, we've [improved how errors are handled](/blog/2024/12/05/react-19#error-handling) to reduce duplication by not re-throwing:
132+
In React 19, we've [improved how errors are handled](/blog/2024/04/25/react-19#error-handling) to reduce duplication by not re-throwing:
133133

134134
- **Uncaught Errors**: Errors that are not caught by an Error Boundary are reported to `window.reportError`.
135135
- **Caught Errors**: Errors that are caught by an Error Boundary are reported to `console.error`.
@@ -499,7 +499,7 @@ function AutoselectingInput() {
499499

500500
### Deprecated: `element.ref` {/*deprecated-element-ref*/}
501501

502-
React 19 supports [`ref` as a prop](/blog/2024/12/05/react-19#ref-as-a-prop), so we're deprecating the `element.ref` in place of `element.props.ref`.
502+
React 19 supports [`ref` as a prop](/blog/2024/04/25/react-19#ref-as-a-prop), so we're deprecating the `element.ref` in place of `element.props.ref`.
503503

504504
Accessing `element.ref` will warn:
505505

src/content/blog/2024/10/21/react-compiler-beta-release.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ Or, if you're using Yarn:
7272
yarn add -D eslint-plugin-react-compiler@beta
7373
</TerminalBlock>
7474

75-
After installation you can enable the linter by [adding it to your ESLint config](/learn/react-compiler#installing-eslint-plugin-react-compiler). Using the linter helps identify Rules of React breakages, making it easier to adopt the compiler when it's fully released.
75+
After installation you can enable the linter by [adding it to your ESLint config](/learn/react-compiler/installation#eslint-integration). Using the linter helps identify Rules of React breakages, making it easier to adopt the compiler when it's fully released.
7676

7777
## Backwards Compatibility {/*backwards-compatibility*/}
7878

79-
React Compiler produces code that depends on runtime APIs added in React 19, but we've since added support for the compiler to also work with React 17 and 18. If you are not on React 19 yet, in the Beta release you can now try out React Compiler by specifying a minimum `target` in your compiler config, and adding `react-compiler-runtime` as a dependency. [You can find docs on this here](/learn/react-compiler#using-react-compiler-with-react-17-or-18).
79+
React Compiler produces code that depends on runtime APIs added in React 19, but we've since added support for the compiler to also work with React 17 and 18. If you are not on React 19 yet, in the Beta release you can now try out React Compiler by specifying a minimum `target` in your compiler config, and adding `react-compiler-runtime` as a dependency. [You can find docs on this here](/reference/react-compiler/configuration#react-17-18).
8080

8181
## Using React Compiler in libraries {/*using-react-compiler-in-libraries*/}
8282

@@ -86,7 +86,7 @@ React Compiler can also be used to compile libraries. Because React Compiler nee
8686

8787
Because your code is pre-compiled, users of your library will not need to have the compiler enabled in order to benefit from the automatic memoization applied to your library. If your library targets apps not yet on React 19, specify a minimum `target` and add `react-compiler-runtime` as a direct dependency. The runtime package will use the correct implementation of APIs depending on the application's version, and polyfill the missing APIs if necessary.
8888

89-
[You can find more docs on this here.](/learn/react-compiler#using-the-compiler-on-libraries)
89+
[You can find more docs on this here.](/reference/react-compiler/compiling-libraries)
9090

9191
## Opening up React Compiler Working Group to everyone {/*opening-up-react-compiler-working-group-to-everyone*/}
9292

src/content/blog/2024/12/05/react-19.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ For more information, see [React DOM Static APIs](/reference/react-dom/static).
355355

356356
Server Components are a new option that allows rendering components ahead of time, before bundling, in an environment separate from your client application or SSR server. This separate environment is the "server" in React Server Components. Server Components can run once at build time on your CI server, or they can be run for each request using a web server.
357357

358-
React 19 includes all of the React Server Components features included from the Canary channel. This means libraries that ship with Server Components can now target React 19 as a peer dependency with a `react-server` [export condition](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md#react-server-conditional-exports) for use in frameworks that support the [Full-stack React Architecture](/learn/creating-a-react-app#which-features-make-up-the-react-teams-full-stack-architecture-vision).
358+
React 19 includes all of the React Server Components features included from the Canary channel. This means libraries that ship with Server Components can now target React 19 as a peer dependency with a `react-server` [export condition](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md#react-server-conditional-exports) for use in frameworks that support the [Full-stack React Architecture](/learn/start-a-new-react-project#which-features-make-up-the-react-teams-full-stack-architecture-vision).
359359

360360

361361
<Note>
@@ -389,7 +389,7 @@ For more info, see the docs for [Directives](/reference/rsc/directives).
389389

390390
Server Actions can be created in Server Components and passed as props to Client Components, or they can be imported and used in Client Components.
391391

392-
For more, see the docs for [React Server Actions](/reference/rsc/server-functions).
392+
For more, see the docs for [React Server Actions](/reference/rsc/server-actions).
393393

394394
## Improvements in React 19 {/*improvements-in-react-19*/}
395395

src/content/community/meetups.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
137137
## Portugal {/*portugal*/}
138138
* [Lisbon](https://www.meetup.com/JavaScript-Lisbon/)
139139

140-
## Scotland (UK) {/*scotland-uk*/}
141-
* [Edinburgh](https://www.meetup.com/React-Scotland/)
142-
143140
## Spain {/*spain*/}
144141
* [Barcelona](https://www.meetup.com/ReactJS-Barcelona/)
145142

src/content/learn/add-react-to-an-existing-project.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ Diyelim ki `example.com`'da başka bir sunucu teknolojisi (Rails gibi) ile oluş
2020

2121
Kurulumu şu şekilde yapmanızı öneririz:
2222

23-
1. React tabanlı framework'lerden birini kullanarak **Uygulamanızın React kısmını oluşturun** [React tabanlı framework'ler](/learn/creating-a-react-app).
24-
2. **Çerçevenizin yapılandırmasında *temel yol*** olarak `/some-app` belirleyin (nasıl olduğu burada: [Next.js](https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath), [Gatsby](https://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/path-prefix/)).
25-
3. **Sunucunuzu veya bir proxy'yi** `/some-app/' altındaki tüm isteklerin React uygulamanız tarafından işleneceği şekilde yapılandırın.
23+
1. **Uygulamanızın React kısmını**, [React tabanlı framework'lerden](/learn/start-a-new-react-project) birini kullanarak oluşturun.
24+
2. **`/some-app` yolunu *base path* olarak belirtin** framework’ünüzün konfigürasyonunda (işte nasıl yapılır: [Next.js](https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath), [Gatsby](https://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/path-prefix/)).
25+
3. **Sunucunuzu veya bir proxy’i yapılandırın** ki `/some-app/` altındaki tüm istekler React uygulamanız tarafından işlenebilsin.
2626

27-
Bu, uygulamanızın React kısmının bu çerçevelerde bulunan [en iyi uygulamalardan](/learn/creating-a-react-app#full-stack-frameworks) yararlanabilmesini sağlar.
27+
Bu, React uygulamanızın o framework’lere dahil edilmiş [en iyi uygulamalardan yararlanmasını](/learn/build-a-react-app-from-scratch#consider-using-a-framework) sağlar.
2828

2929
Birçok React tabanlı kütüphaneler, ön ve arka yüz geliştirmede kullanılabilir ve React uygulamanızın sunucudan yararlanmasına izin verir. Ancak, sunucuda JavaScript çalıştıramasanız veya istemeseniz bile aynı yaklaşımı kullanabilirsiniz. Bu durumda HTML/CSS/JS dışa aktarımını (Next.js için [`next export` çıktısı](https://nextjs.org/docs/advanced-features/static-html-export), Gatsby için varsayılan) bunun yerine `/some-app/` konumunda sunun.
3030

@@ -149,7 +149,7 @@ root.render(<NavigationBar />);
149149

150150
`index.html'deki` orijinal HTML içeriğinin nasıl korunduğuna dikkat edin, ancak kendi `NavigationBar` React bileşeniniz artık HTML'nizden `<nav id="navigation">` içinde görünüyor. React bileşenlerini mevcut bir HTML sayfasında render etme hakkında daha fazla bilgi edinmek için [`createRoot` dökümantasyonunu](/reference/react-dom/client/createRoot#rendering-a-page-partially-built-with-react) okuyun.
151151

152-
Mevcut bir projede React'i benimsediğinizde, küçük etkileşimli bileşenlerle (butonlar gibi) başlamak ve sonunda tüm sayfanız React ile oluşturulana kadar kademeli olarak “yukarı doğru” ilerlemek yaygındır. Bu noktaya ulaşırsanız, React'ten en iyi şekilde yararlanmak için hemen ardından [bir React framework'üne](/learn/creating-a-react-app) geçmenizi öneririz.
152+
Mevcut bir projeye React eklerken, genellikle küçük etkileşimli bileşenlerle (örneğin butonlar) başlamak ve ardından yavaş yavaş “yukarı doğru ilerleyerek” sonunda tüm sayfanızı React ile oluşturmak yaygındır. Bu noktaya ulaşırsanız, Reactten en iyi şekilde yararlanmak için hemen [bir React frameworküne](/learn/start-a-new-react-project) geçmenizi öneririz.
153153

154154
## React Native'i mevcut bir yerel mobil uygulamada kullanma {/*using-react-native-in-an-existing-native-mobile-app*/}
155155

0 commit comments

Comments
 (0)