Skip to content

Commit b4b5a2d

Browse files
authored
Merge pull request #163 from reactjs/sync-47e64bf7
Sync with react.dev @ 47e64bf
2 parents ae9e10a + 6d3cb1b commit b4b5a2d

5 files changed

Lines changed: 31 additions & 70 deletions

File tree

src/content/learn/editor-setup.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ Baadhi ya vihariri huja na maumbile haya yakiwa yamejengwa ndani, lakini vingine
3131

3232
### Linting {/*linting*/}
3333

34-
<<<<<<< HEAD
3534
Code linters hupata matatizo katika kodi yako unapoandika, zikikusaidia kuyarekebisha mapema. [ESLint](https://eslint.org/) ni linter maarufu ya chanzo wazi (open source) kwa ajili ya JavaScript.
3635
=======
37-
Code linters find problems in your code as you write, helping you fix them early. [ESLint](https://eslint.org/) is a popular, open source linter for JavaScript.
38-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
3936

4037
* [Sakinisha ESLint kwa mpangilio uliopendekezwa kwa React](https://www.npmjs.com/package/eslint-config-react-app) (hakikisha una [Node imesakinishwa!](https://nodejs.org/en/download/current/))
4138
* [Unganisha ESLint katika VSCode na kiendelezi rasmi](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)

src/content/learn/react-compiler/installation.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,32 @@ module.exports = {
6464

6565
### Vite {/*vite*/}
6666

67-
If you use Vite, you can add the plugin to vite-plugin-react:
67+
If you use Vite with version 6.0.0 or later of `@vitejs/plugin-react`, you can use the `reactCompilerPreset`:
6868

69-
```js {3,9}
69+
<TerminalBlock>
70+
npm install -D @rolldown/plugin-babel
71+
</TerminalBlock>
72+
73+
```js {3-4,9-11}
74+
// vite.config.js
75+
import { defineConfig } from 'vite';
76+
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
77+
import babel from '@rolldown/plugin-babel';
78+
79+
export default defineConfig({
80+
plugins: [
81+
react(),
82+
babel({
83+
presets: [reactCompilerPreset()]
84+
}),
85+
],
86+
});
87+
```
88+
89+
<Note>
90+
In `@vitejs/plugin-react@6.0.0`, the inline Babel option was removed. If you're using an older version, you can use:
91+
92+
```js
7093
// vite.config.js
7194
import { defineConfig } from 'vite';
7295
import react from '@vitejs/plugin-react';
@@ -81,26 +104,21 @@ export default defineConfig({
81104
],
82105
});
83106
```
107+
</Note>
84108

85-
Alternatively, if you prefer a separate Babel plugin for Vite:
86-
87-
<TerminalBlock>
88-
npm install -D vite-plugin-babel
89-
</TerminalBlock>
109+
Alternatively, you can use the Babel plugin directly with `@rolldown/plugin-babel`:
90110

91-
```js {2,11}
111+
```js {3,9}
92112
// vite.config.js
93-
import babel from 'vite-plugin-babel';
94113
import { defineConfig } from 'vite';
95114
import react from '@vitejs/plugin-react';
115+
import babel from '@rolldown/plugin-babel';
96116

97117
export default defineConfig({
98118
plugins: [
99119
react(),
100120
babel({
101-
babelConfig: {
102-
plugins: ['babel-plugin-react-compiler'],
103-
},
121+
plugins: ['babel-plugin-react-compiler'],
104122
}),
105123
],
106124
});

src/content/learn/thinking-in-react.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,10 @@ Anza kwa kuchora visanduku kuzunguka kila kijenzi na kijenzi kidogo kwenye kiigi
3737

3838
Kulingana na msingi wako, unaweza kufikiria kugawanya muundo katika vijenzi kwa njia tofauti:
3939

40-
<<<<<<< HEAD
4140
* **Programming**--tumia mbinu zile zile za kuamua ikiwa unapaswa kuunda kitendaji kipya au object. Mbinu moja kama hiyo ni [kanuni ya uwajibikaji mmoja (single responsibility principle)](https://en.wikipedia.org/wiki/Single_responsibility_principle), yaani, kijenzi kinapaswa kufanya jambo moja tu. Ikiwa kitaishia kukua, inapaswa kigawanywe kiwe vijenzi vidogo.
4241
* **CSS**--fikiria ni nini ungetengeneza viteule vya darasa. (Hatahivyo, vijenzi ni vidogo kwa kiasi fulani.)
4342
* **Design**--fikiria jinsi unavyoweza kupanga safu za muundo.
4443
=======
45-
* **Programming**--use the same techniques for deciding if you should create a new function or object. One such technique is the [separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns), that is, a component should ideally only be concerned with one thing. If it ends up growing, it should be decomposed into smaller subcomponents.
46-
* **CSS**--consider what you would make class selectors for. (However, components are a bit less granular.)
47-
* **Design**--consider how you would organize the design's layers.
48-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
4944

5045
Ikiwa JSON yako imeundwa vizuri, mara nyingi utapata kwamba inaelekeza kwa muundo wa vijenzi vya UI yako. Hiyo ni kwa sababu UI na miundo ya data mara nyingi huwa na usanifu sawa wa habari--yaani, umbo sawa. Tenganisha UI yako katika vijenzi, ambapo kila kijenzi kinalingana na kipande kimoja cha muundo yako wa data.
5146

@@ -232,19 +227,10 @@ Kilichobaki labda ni hali.
232227

233228
Wacha tupitie moja baada ya nyingine tena:
234229

235-
<<<<<<< HEAD
236230
1. Orodha asili ya bidhaa **imepitishwa kama vifaa, kwa hivyo haijabainishwa.**
237231
2. Maandishi ya utafutaji yanaonekana kuwa ya hali kwani yanabadilika kwa wakati na hayawezi kukokotwa kutoka kwa chochote.
238232
3. Thamani ya kisanduku cha kuteua inaonekana kuwa hali kwani inabadilika kwa wakati na haiwezi kukokotwa kutoka kwa chochote.
239233
4. Orodha iliyochujwa ya bidhaa **haijabainishwa kwa sababu inaweza kukokotwa** kwa kuchukua orodha asili ya bidhaa na kuichuja kulingana na maandishi ya utafutaji na thamani ya kisanduku cha kuteua.
240-
=======
241-
1. The original list of products is **passed in as props, so it's not state.**
242-
2. The search text seems to be state since it changes over time and can't be computed from anything.
243-
3. The value of the checkbox seems to be state since it changes over time and can't be computed from anything.
244-
4. The filtered list of products **isn't state because it can be computed** by taking the original list of products and filtering it according to the search text and value of the checkbox.
245-
246-
This means only the search text and the value of the checkbox are state! Nicely done!
247-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
248234

249235
Hii ina maana kwamba ni maandishi ya utafutaji pekee na thamani ya kisanduku cha kuteua ndizo zilizotajwa! Imefanywa vizuri!
250236
<DeepDive>
@@ -277,23 +263,13 @@ In the previous step, you found two pieces of state in this application: the sea
277263

278264
Katika hatua ya awali, ulipata vipande viwili vya hali katika programu hii: maandishi ya ingizo ya utafutaji, na thamani ya kisanduku cha kuteua. Katika mfano huu, daima huonekana pamoja, kwa hiyo ni mantiki kuviweka katika sehemu moja.
279265

280-
<<<<<<< HEAD
281266
Sasa wacha tupitie mkakati wetu kwao:
282267

283268
1. **Tambua vijenzi vinavyotumia hali:**
284269
* `ProductTable` inahitaji kuchuja orodha ya bidhaa kulingana na hali hiyo (maandishi ya utafutaji na thamani ya kisanduku cha kuteua).
285270
* `SearchBar` inahitaji kuonyesha hali hiyo (maandishi ya utafutaji na thamani ya kisanduku cha kuteua).
286271
1. **Tafuta mzazi wao wa kawaida:** Kijenzi mzazi cha kwanza ambacho vijenzi vyote viwili hushiriki ni `FilterableProductTable`.
287272
2. **Amua mahali pa kuishi**: Tutaweka maandishi ya kichujio na thamani za hali zilizochaguliwa katika `FilterableProductTable`.
288-
=======
289-
1. **Identify components that use state:**
290-
* `ProductTable` needs to filter the product list based on that state (search text and checkbox value).
291-
* `SearchBar` needs to display that state (search text and checkbox value).
292-
2. **Find their common parent:** The first parent component both components share is `FilterableProductTable`.
293-
3. **Decide where the state lives**: We'll keep the filter text and checked state values in `FilterableProductTable`.
294-
295-
So the state values will live in `FilterableProductTable`.
296-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
297273

298274
Kwa hivyo state thamani zitaishi katika `FilterableProductTable`.
299275

@@ -481,16 +457,7 @@ function SearchBar({ filterText, inStockOnly }) {
481457
482458
Hata hivyo, bado hujaongeza msimbo wowote ili kujibu vitendo vya mtumiaji kama vile kuandika. Hii itakuwa hatua yako ya mwisho.
483459
484-
<<<<<<< HEAD
485460
## Hatua ya 5: Ongeza mtiririko wa data kinyume {/*step-5-add-inverse-data-flow*/}
486-
=======
487-
488-
## Step 5: Add inverse data flow {/*step-5-add-inverse-data-flow*/}
489-
490-
Currently your app renders correctly with props and state flowing down the hierarchy. But to change the state according to user input, you will need to support data flowing the other way: the form components deep in the hierarchy need to update the state in `FilterableProductTable`.
491-
492-
React makes this data flow explicit, but it requires a little more typing than two-way data binding. If you try to type or check the box in the example above, you'll see that React ignores your input. This is intentional. By writing `<input value={filterText} />`, you've set the `value` prop of the `input` to always be equal to the `filterText` state passed in from `FilterableProductTable`. Since `filterText` state is never set, the input never changes.
493-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
494461
495462
You want to make it so whenever the user changes the form inputs, the state updates to reflect those changes. The state is owned by `FilterableProductTable`, so only it can call `setFilterText` and `setInStockOnly`. To let `SearchBar` update the `FilterableProductTable`'s state, you need to pass these functions down to `SearchBar`:
496463

src/content/learn/tutorial-tic-tac-toe.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,7 @@ import './styles.css';
337337
import App from './App';
338338
```
339339

340-
<<<<<<< HEAD
341340
Mstari wa 1-5 unaleta vipande vyote muhimu pamoja:
342-
=======
343-
Lines 1-5 bring all the necessary pieces together:
344-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
345341

346342
* React
347343
* Maktaba ya React ya kuwasiliana na kivinjari cha wavuti (React DOM)
@@ -555,11 +551,7 @@ export default function Board() {
555551
}
556552
```
557553

558-
<<<<<<< HEAD
559554
Angalia jinsi, kinyume na `div`s za kivinjari, viungo vyako `Board` na `Square` lazima vianze na herufi kubwa.
560-
=======
561-
Note how unlike the browser `div`s, your own components `Board` and `Square` must start with a capital letter.
562-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
563555

564556
Hebu tuangalie:
565557

@@ -1102,11 +1094,7 @@ function Square({ value, onSquareClick }) {
11021094
}
11031095
```
11041096
1105-
<<<<<<< HEAD
11061097
Sasa utaunganisha kipengele cha `onSquareClick` na function katika sehemu ya `Board` utakayoita `handleClick`. Ili kuunganisha `onSquareClick` na `handleClick`, utapita function kwa kipengele cha `onSquareClick` cha sehemu ya kwanza ya `Square`:
1107-
=======
1108-
Now you'll connect the `onSquareClick` prop to a function in the `Board` component that you'll name `handleClick`. To connect `onSquareClick` to `handleClick` you'll pass a function to the `onSquareClick` prop of the first `Square` component:
1109-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
11101098
11111099
```js
11121100
export default function Board() {
@@ -2085,22 +2073,13 @@ export default function Game() {
20852073
}
20862074
```
20872075
2088-
<<<<<<< HEAD
20892076
Unaweza kuona jinsi kanuni yako inavyopaswa kuonekana hapa chini. Kumbuka kwamba unapaswa kuona hitilafu katika koni ya zana za mende inayosema:
2090-
=======
2091-
You can see what your code should look like below. Note that you should see an error in the developer tools console that says:
2092-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
20932077
20942078
<ConsoleBlock level="warning">
20952079
Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of &#96;Game&#96;.
20962080
</ConsoleBlock>
2097-
<<<<<<< HEAD
20982081
20992082
Utarekebisha hitilafu hii katika sehemu inayofuata.
2100-
=======
2101-
2102-
You'll fix this error in the next section.
2103-
>>>>>>> abe931a8cb3aee3e8b15ef7e187214789164162a
21042083
21052084
<Sandpack>
21062085

src/content/reference/react/useOptimistic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function handleClick() {
8383
8484
#### How optimistic state works {/*how-optimistic-state-works*/}
8585
86-
`useOptimistic` lets you show a temporary value while a Action is in progress:
86+
`useOptimistic` lets you show a temporary value while an Action is in progress:
8787
8888
```js
8989
const [value, setValue] = useState('a');

0 commit comments

Comments
 (0)