Skip to content

Commit 7c61f10

Browse files
Merge pull request #632 from reactjs/sync-65d297e9
Sync with react.dev @ 65d297e
2 parents 4ed8c88 + 1dcae39 commit 7c61f10

20 files changed

+196
-30
lines changed
75.6 KB
Binary file not shown.
64.9 KB
Binary file not shown.
Binary file not shown.

src/components/Layout/HomeContent.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,8 @@ function ExampleLayout({
865865
</div>
866866
<div
867867
ref={contentRef}
868-
className="relative mt-0 lg:-my-20 w-full p-2.5 xs:p-5 lg:p-10 flex grow justify-center">
868+
className="relative mt-0 lg:-my-20 w-full p-2.5 xs:p-5 lg:p-10 flex grow justify-center"
869+
dir="ltr">
869870
{right}
870871
<div
871872
className={cn(

src/components/MDX/Sandpack/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const template = {
22
'/src/index.js': {
33
hidden: true,
4-
code: `import React, { StrictMode } from "react";
4+
code: `import { StrictMode } from "react";
55
import { createRoot } from "react-dom/client";
66
import "./styles.css";
77

src/components/PageHeading.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function PageHeading({
2727
tags = [],
2828
breadcrumbs,
2929
}: PageHeadingProps) {
30-
console.log('version', version);
3130
return (
3231
<div className="px-5 sm:px-12 pt-3.5">
3332
<div className="max-w-4xl ms-0 2xl:mx-auto">

src/components/Seo.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ export const Seo = withRouter(
124124
)}
125125
<link
126126
rel="preload"
127-
href="/fonts/Source-Code-Pro-Regular.woff2"
127+
href="https://react.dev/fonts/Source-Code-Pro-Regular.woff2"
128+
as="font"
129+
type="font/woff2"
130+
crossOrigin="anonymous"
131+
/>
132+
<link
133+
rel="preload"
134+
href="https://react.dev/fonts/Source-Code-Pro-Bold.woff2"
128135
as="font"
129136
type="font/woff2"
130137
crossOrigin="anonymous"

src/content/community/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ Her topluluk, binlerce React kullanıcısından oluşur.
2929

3030
## Haberler {/*news*/}
3131

32-
React ile ilgili en güncel haberler için, [Twitter'da **@reactjs** hesabını](https://twitter.com/reactjs) ve Bu website'de bulunan [React Resmi Blogunu](/blog/) takip edin.
32+
React ile ilgili en güncel haberler için, [Twitter da **@reactjs** hesabını](https://twitter.com/reactjs), [Bluesky da **@react.dev** hesabını](https://bsky.app/profile/react.dev) ve bu sitedeki [Resmi React blog'unu](/blog/) takip edebilirsiniz.

src/content/community/meetups.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
3838

3939
## Canada {/*canada*/}
4040
* [Halifax, NS](https://www.meetup.com/Halifax-ReactJS-Meetup/)
41-
* [Montreal, QC - React Native](https://www.meetup.com/fr-FR/React-Native-MTL/)
41+
* [Montreal, QC](https://guild.host/react-montreal/)
4242
* [Vancouver, BC](https://www.meetup.com/ReactJS-Vancouver-Meetup/)
4343
* [Ottawa, ON](https://www.meetup.com/Ottawa-ReactJS-Meetup/)
4444
* [Saskatoon, SK](https://www.meetup.com/saskatoon-react-meetup/)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Similarly, if you rely on the apps using your framework to split the code, you m
116116
Splitting code by route, when integrated with bundling and data fetching, can reduce the initial load time of your app and the time it takes for the largest visible content of the app to render ([Largest Contentful Paint](https://web.dev/articles/lcp)).
117117

118118
For code-splitting instructions, see your build tool docs:
119-
- [Vite build optimizations](https://v3.vitejs.dev/guide/features.html#build-optimizations)
119+
- [Vite build optimizations](https://vite.dev/guide/features.html#build-optimizations)
120120
- [Parcel code splitting](https://parceljs.org/features/code-splitting/)
121121
- [Rsbuild code splitting](https://rsbuild.dev/guide/optimization/code-splitting)
122122

src/content/learn/preserving-and-resetting-state.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ export default function ContactList() {
20282028
<label>
20292029
<input
20302030
type="checkbox"
2031-
value={reverse}
2031+
checked={reverse}
20322032
onChange={e => {
20332033
setReverse(e.target.checked)
20342034
}}
@@ -2127,7 +2127,7 @@ export default function ContactList() {
21272127
<label>
21282128
<input
21292129
type="checkbox"
2130-
value={reverse}
2130+
checked={reverse}
21312131
onChange={e => {
21322132
setReverse(e.target.checked)
21332133
}}

src/content/learn/removing-effect-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ export default function Timer() {
12411241
12421242
</Sandpack>
12431243
1244-
Efekt içinde `count` okumak yerine, React'e bir `c => c + 1` komutu ("bu sayıyı artır!") iletirsiniz. React bunu bir sonraki render'da uygulayacaktır. Ve artık Efektinizin içinde `count` değerini okumanıza gerek olmadığından, Efektinizin bağımlılıklarını boş tutabilirsiniz (`[]`). Bu, Efektinizin her tikte aralığı yeniden oluşturmasını önler.
1244+
`count` değerini Efekt içinde okumak yerine, React'e `c => c + 1` talimatını ("bu sayıyı artır!") verirsiniz. React bu işlemi bir sonraki render'da uygular. Artık Efekt'in içinde `count` değerini okumanıza gerek kalmadığı için, Efekt'in bağımlılık dizisini boş (`[]`) bırakabilirsiniz. Bu da, her tikte Efekt'in yeniden oluşturulmasını engeller.
12451245
12461246
</Solution>
12471247

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ export default function ChatRoom({ roomId }) {
820820
// ...
821821
```
822822

823-
başka bir Hook'a girdi olarak nasıl illetiğinizi farkedin:
823+
ve onu başka bir Hook'a girdi olarak vermek:
824824
825825
```js {6}
826826
export default function ChatRoom({ roomId }) {
@@ -2087,7 +2087,6 @@ export function useCounter(delay) {
20872087
<Sandpack>
20882088
20892089
```js
2090-
import { useState } from 'react';
20912090
import { useCounter } from './useCounter.js';
20922091

20932092
export default function Counter() {

src/content/learn/separating-events-from-effects.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ function ChatRoom({ roomId, theme }) {
439439
// ...
440440
```
441441
442-
Bu sorunu çözer. Efektinizin bağımlılıkları listesinden `onConnected` öğesini *kaldırmanız* gerektiğini unutmayın. **Efekt olayları reaktif değildir ve bağımlılıklardan çıkarılmalıdır.**
442+
Bu, problemi çözer. Dikkat etmen gereken nokta, Efekt içinde artık kullanılmadığı için `theme` öğesini bağımlılıklar listesinden *çıkarman* gerektiğidir. Ayrıca `onConnected` öğesini listeye *eklemene* de gerek yoktur çünkü **Efekt Olayları reaktif değildir ve bağımlılıklardan çıkarılmalıdır.**
443443
444444
Yeni davranışın beklediğiniz gibi çalıştığını doğrulayın:
445445
@@ -789,7 +789,6 @@ body {
789789
790790
</Sandpack>
791791
792-
793792
Bu kodla ilgili sorun, bağımlılık linterinin bastırılmasıdır. Bastırmayı kaldırırsanız, bu Efektin `handleMove` fonksiyonuna bağlı olması gerektiğini görürsünüz. Bu mantıklıdır: `handleMove` bileşen gövdesi içinde bildirilir, bu da onu reaktif bir değer yapar. Her reaktif değer bir bağımlılık olarak belirtilmelidir, aksi takdirde zaman içinde eskimesi olasıdır!
794793
795794
Orijinal kodun yazarı, Effect'in herhangi bir reaktif değere bağlı olmadığını (`[]`) söyleyerek React'e "yalan söylemiştir". Bu nedenle React, `canMove` değiştikten sonra (ve onunla birlikte `handleMove`) Efekti yeniden senkronize etmedi. React, Efekti yeniden senkronize etmediği için, dinleyici olarak eklenen `handleMove`, ilk render sırasında oluşturulan `handleMove` fonksiyonudur. İlk render sırasında `canMove` `true` idi, bu yüzden ilk renderdan `handleMove` sonsuza kadar bu değeri görecektir.
@@ -886,8 +885,8 @@ Bu bölümde, React'in kararlı bir sürümünde henüz yayınlanmamış **deney
886885
887886
Efekt Olayları, kullanma şekliniz açısından oldukça sınırlıdır:
888887
889-
* **Sadece Efektlerin içinden çağırın.**
890-
* **Asla diğer bileşenlere veya Hook'lara aktarmayın.**
888+
- **Sadece Efektlerin içinden çağırın.**
889+
- **Asla diğer bileşenlere veya Hook'lara aktarmayın.**
891890
892891
Örneğin, bir Efekt olayını şu şekilde bildirmeyin ve geçirmeyin:
893892
@@ -1216,7 +1215,6 @@ export default function Timer() {
12161215
}
12171216
```
12181217
1219-
12201218
```css
12211219
button { margin: 10px; }
12221220
```
@@ -1233,7 +1231,7 @@ Bu örnekte, aralık gecikmesini özelleştirebilirsiniz. Bu, iki düğme taraf
12331231

12341232
<Hint>
12351233

1236-
Effect olayları içindeki kod reaktif değildir. `setInterval` çağrısının yeniden çalışmasını _istediğiniz_ durumlar var?
1234+
Effect olayları içindeki kod reaktif değildir. `setInterval` çağrısının yeniden çalışmasını *istediğiniz* durumlar var?
12371235

12381236
</Hint>
12391237

@@ -1313,7 +1311,6 @@ export default function Timer() {
13131311
}
13141312
```
13151313

1316-
13171314
```css
13181315
button { margin: 10px; }
13191316
```
@@ -1402,7 +1399,7 @@ button { margin: 10px; }
14021399

14031400
</Sandpack>
14041401

1405-
Genel olarak, bir kod parçasının *amacından* ziyade *zamanlamasına* odaklanan `onMount` gibi fonksiyonlara şüpheyle yaklaşmalısınız. İlk başta "daha açıklayıcı" gelebilir ancak amacınızı gizler. Genel bir kural olarak, Efekt olayları *kullanıcının* bakış açısından gerçekleşen bir şeye karşılık gelmelidir. Örneğin, `onMessage`, `onTick`, `onVisit` veya `onConnected` iyi Effect olay adlarıdır. İçlerindeki kodun muhtemelen reaktif olması gerekmeyecektir. Öte yandan, `onMount`, `onUpdate`, `onUnmount` veya `onAfterRender` o kadar geneldir ki, yanlışlıkla * reaktif olması gereken * kodları bunlara koymak kolaydır. Bu nedenle, Efekt olaylarınızı bazı kodların ne zaman çalıştığına göre değil, *kullanıcının ne olduğunu düşündüğüne göre* adlandırmalısınız.
1402+
Genel olarak, bir kod parçasının *amacından* ziyade *zamanlamasına* odaklanan `onMount` gibi fonksiyonlara şüpheyle yaklaşmalısınız. İlk başta "daha açıklayıcı" gelebilir ancak amacınızı gizler. Genel bir kural olarak, Efekt olayları *kullanıcının* bakış açısından gerçekleşen bir şeye karşılık gelmelidir. Örneğin, `onMessage`, `onTick`, `onVisit` veya `onConnected` iyi Effect olay adlarıdır. İçlerindeki kodun muhtemelen reaktif olması gerekmeyecektir. Öte yandan, `onMount`, `onUpdate`, `onUnmount` veya `onAfterRender` o kadar geneldir ki, yanlışlıkla *reaktif olması gereken* kodları bunlara koymak kolaydır. Bu nedenle, Efekt olaylarınızı bazı kodların ne zaman çalıştığına göre değil, *kullanıcının ne olduğunu düşündüğüne göre* adlandırmalısınız.
14061403

14071404
</Solution>
14081405

@@ -1837,10 +1834,8 @@ label { display: block; margin-top: 10px; }
18371834

18381835
</Sandpack>
18391836

1840-
18411837
Bu, oda değiştirdiğinizde önceden planlanmış (ancak henüz görüntülenmemiş) bildirimlerin iptal edilmesini sağlar.
18421838

1843-
18441839
</Solution>
18451840

18461841
</Challenges>

src/content/reference/react-dom/preinit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The `preinit` function provides the browser with a hint that it should start dow
4848
* `options`: an object. It contains the following properties:
4949
* `as`: a required string. The type of resource. Its possible values are `script` and `style`.
5050
* `precedence`: a string. Required with stylesheets. Says where to insert the stylesheet relative to others. Stylesheets with higher precedence can override those with lower precedence. The possible values are `reset`, `low`, `medium`, `high`.
51-
* `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`. It is required when `as` is set to `"fetch"`.
51+
* `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`.
5252
* `integrity`: a string. A cryptographic hash of the resource, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
5353
* `nonce`: a string. A cryptographic [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy.
5454
* `fetchPriority`: a string. Suggests a relative priority for fetching the resource. The possible values are `auto` (the default), `high`, and `low`.

src/content/reference/react/useTransition.md

Lines changed: 160 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function CheckoutForm() {
163163

164164
The function passed to `startTransition` is called the "Action". You can update state and (optionally) perform side effects within an Action, and the work will be done in the background without blocking user interactions on the page. A Transition can include multiple Actions, and while a Transition is in progress, your UI stays responsive. For example, if the user clicks a tab but then changes their mind and clicks another tab, the second click will be immediately handled without waiting for the first update to finish.
165165

166-
To give the user feedback about in-progress Transitions, to `isPending` state switches to `true` at the first call to `startTransition`, and stays `true` until all Actions complete and the final state is shown to the user. Transitions ensure side effects in Actions to complete in order to [prevent unwanted loading indicators](#preventing-unwanted-loading-indicators), and you can provide immediate feedback while the Transition is in progress with `useOptimistic`.
166+
To give the user feedback about in-progress Transitions, the `isPending` state switches to `true` at the first call to `startTransition`, and stays `true` until all Actions complete and the final state is shown to the user. Transitions ensure side effects in Actions to complete in order to [prevent unwanted loading indicators](#preventing-unwanted-loading-indicators), and you can provide immediate feedback while the Transition is in progress with `useOptimistic`.
167167

168168
<Recipes titleText="The difference between Actions and regular event handling">
169169

@@ -1949,3 +1949,162 @@ When clicking multiple times, it's possible for previous requests to finish afte
19491949
This is expected, because Actions within a Transition do not guarantee execution order. For common use cases, React provides higher-level abstractions like [`useActionState`](/reference/react/useActionState) and [`<form>` actions](/reference/react-dom/components/form) that handle ordering for you. For advanced use cases, you'll need to implement your own queuing and abort logic to handle this.
19501950
19511951
1952+
Example of `useActionState` handling execution order:
1953+
1954+
<Sandpack>
1955+
1956+
```json package.json hidden
1957+
{
1958+
"dependencies": {
1959+
"react": "beta",
1960+
"react-dom": "beta"
1961+
},
1962+
"scripts": {
1963+
"start": "react-scripts start",
1964+
"build": "react-scripts build",
1965+
"test": "react-scripts test --env=jsdom",
1966+
"eject": "react-scripts eject"
1967+
}
1968+
}
1969+
```
1970+
1971+
```js src/App.js
1972+
import { useState, useActionState } from "react";
1973+
import { updateQuantity } from "./api";
1974+
import Item from "./Item";
1975+
import Total from "./Total";
1976+
1977+
export default function App({}) {
1978+
// Store the actual quantity in separate state to show the mismatch.
1979+
const [clientQuantity, setClientQuantity] = useState(1);
1980+
const [quantity, updateQuantityAction, isPending] = useActionState(
1981+
async (prevState, payload) => {
1982+
setClientQuantity(payload);
1983+
const savedQuantity = await updateQuantity(payload);
1984+
return savedQuantity; // Return the new quantity to update the state
1985+
},
1986+
1 // Initial quantity
1987+
);
1988+
1989+
return (
1990+
<div>
1991+
<h1>Checkout</h1>
1992+
<Item action={updateQuantityAction}/>
1993+
<hr />
1994+
<Total clientQuantity={clientQuantity} savedQuantity={quantity} isPending={isPending} />
1995+
</div>
1996+
);
1997+
}
1998+
1999+
```
2000+
2001+
```js src/Item.js
2002+
import {startTransition} from 'react';
2003+
2004+
export default function Item({action}) {
2005+
function handleChange(e) {
2006+
// Update the quantity in an Action.
2007+
startTransition(() => {
2008+
action(e.target.value);
2009+
});
2010+
}
2011+
return (
2012+
<div className="item">
2013+
<span>Eras Tour Tickets</span>
2014+
<label htmlFor="name">Quantity: </label>
2015+
<input
2016+
type="number"
2017+
onChange={handleChange}
2018+
defaultValue={1}
2019+
min={1}
2020+
/>
2021+
</div>
2022+
)
2023+
}
2024+
```
2025+
2026+
```js src/Total.js
2027+
const intl = new Intl.NumberFormat("en-US", {
2028+
style: "currency",
2029+
currency: "USD"
2030+
});
2031+
2032+
export default function Total({ clientQuantity, savedQuantity, isPending }) {
2033+
return (
2034+
<div className="total">
2035+
<span>Total:</span>
2036+
<div>
2037+
<div>
2038+
{isPending
2039+
? "🌀 Updating..."
2040+
: `${intl.format(savedQuantity * 9999)}`}
2041+
</div>
2042+
<div className="error">
2043+
{!isPending &&
2044+
clientQuantity !== savedQuantity &&
2045+
`Wrong total, expected: ${intl.format(clientQuantity * 9999)}`}
2046+
</div>
2047+
</div>
2048+
</div>
2049+
);
2050+
}
2051+
```
2052+
2053+
```js src/api.js
2054+
let firstRequest = true;
2055+
export async function updateQuantity(newName) {
2056+
return new Promise((resolve, reject) => {
2057+
if (firstRequest === true) {
2058+
firstRequest = false;
2059+
setTimeout(() => {
2060+
firstRequest = true;
2061+
resolve(newName);
2062+
// Simulate every other request being slower
2063+
}, 1000);
2064+
} else {
2065+
setTimeout(() => {
2066+
resolve(newName);
2067+
}, 50);
2068+
}
2069+
});
2070+
}
2071+
```
2072+
2073+
```css
2074+
.item {
2075+
display: flex;
2076+
align-items: center;
2077+
justify-content: start;
2078+
}
2079+
2080+
.item label {
2081+
flex: 1;
2082+
text-align: right;
2083+
}
2084+
2085+
.item input {
2086+
margin-left: 4px;
2087+
width: 60px;
2088+
padding: 4px;
2089+
}
2090+
2091+
.total {
2092+
height: 50px;
2093+
line-height: 25px;
2094+
display: flex;
2095+
align-content: center;
2096+
justify-content: space-between;
2097+
}
2098+
2099+
.total div {
2100+
display: flex;
2101+
flex-direction: column;
2102+
align-items: flex-end;
2103+
}
2104+
2105+
.error {
2106+
color: red;
2107+
}
2108+
```
2109+
2110+
</Sandpack>

src/content/reference/rsc/server-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ To support Server Functions as a bundler or framework, we recommend pinning to a
2828

2929
</Note>
3030

31-
When a Server Functions is defined with the [`"use server"`](/reference/rsc/use-server) directive, your framework will automatically create a reference to the server function, and pass that reference to the Client Component. When that function is called on the client, React will send a request to the server to execute the function, and return the result.
31+
When a Server Function is defined with the [`"use server"`](/reference/rsc/use-server) directive, your framework will automatically create a reference to the server function, and pass that reference to the Client Component. When that function is called on the client, React will send a request to the server to execute the function, and return the result.
3232

3333
Server Functions can be created in Server Components and passed as props to Client Components, or they can be imported and used in Client Components.
3434

src/content/warnings/react-dom-test-utils.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
title: react-dom/test-utils Deprecation Warnings
33
---
44

5-
TODO: update for 19?
6-
75
## ReactDOMTestUtils.act() warning {/*reactdomtestutilsact-warning*/}
86

97
`act` from `react-dom/test-utils` has been deprecated in favor of `act` from `react`.

src/content/warnings/react-test-renderer.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
title: react-test-renderer Deprecation Warnings
33
---
44

5-
TODO: Update this for 19?
6-
75
## ReactTestRenderer.create() warning {/*reacttestrenderercreate-warning*/}
86

97
react-test-renderer is deprecated. A warning will fire whenever calling ReactTestRenderer.create() or ReactShallowRender.render(). The react-test-renderer package will remain available on NPM but will not be maintained and may break with new React features or changes to React's internals.

0 commit comments

Comments
 (0)