Skip to content

Commit 2052013

Browse files
authored
Merge branch 'main' into sync-152a471a
2 parents 593af3f + 355026b commit 2052013

6 files changed

Lines changed: 331 additions & 713 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"remark-gfm": "^3.0.1"
4848
},
4949
"devDependencies": {
50-
"@babel/core": "^7.12.9",
50+
"@babel/core": "^7.29.6",
5151
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
5252
"@babel/preset-react": "^7.18.6",
5353
"@mdx-js/mdx": "^2.1.3",
@@ -67,7 +67,7 @@
6767
"babel-eslint": "10.x",
6868
"babel-plugin-react-compiler": "^1.0.0",
6969
"chalk": "4.1.2",
70-
"esbuild": "^0.25.0",
70+
"esbuild": "^0.28.1",
7171
"eslint": "7.x",
7272
"eslint-config-next": "12.0.3",
7373
"eslint-config-react-app": "^5.2.1",
@@ -91,7 +91,7 @@
9191
"postcss-flexbugs-fixes": "4.2.1",
9292
"postcss-preset-env": "^6.7.0",
9393
"prettier": "^2.5.1",
94-
"react-server-dom-webpack": "^19.2.4",
94+
"react-server-dom-webpack": "^19.2.5",
9595
"reading-time": "^1.2.0",
9696
"remark": "^12.0.1",
9797
"remark-external-links": "^7.0.0",

src/content/learn/editor-setup.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ 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.
36-
=======
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-
>>>>>>> 152a471aa9ac2f6f0f3e64c04f39da790d40cf61
3935

4036
* [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/))
4137
* [Unganisha ESLint katika VSCode na kiendelezi rasmi](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,9 @@ 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.
44-
=======
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-
>>>>>>> 152a471aa9ac2f6f0f3e64c04f39da790d40cf61
4943

5044
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.
5145

@@ -232,19 +226,10 @@ Kilichobaki labda ni hali.
232226

233227
Wacha tupitie moja baada ya nyingine tena:
234228

235-
<<<<<<< HEAD
236229
1. Orodha asili ya bidhaa **imepitishwa kama vifaa, kwa hivyo haijabainishwa.**
237230
2. Maandishi ya utafutaji yanaonekana kuwa ya hali kwani yanabadilika kwa wakati na hayawezi kukokotwa kutoka kwa chochote.
238231
3. Thamani ya kisanduku cha kuteua inaonekana kuwa hali kwani inabadilika kwa wakati na haiwezi kukokotwa kutoka kwa chochote.
239232
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-
>>>>>>> 152a471aa9ac2f6f0f3e64c04f39da790d40cf61
248233

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

278263
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.
279264

280-
<<<<<<< HEAD
281265
Sasa wacha tupitie mkakati wetu kwao:
282266

283267
1. **Tambua vijenzi vinavyotumia hali:**
284268
* `ProductTable` inahitaji kuchuja orodha ya bidhaa kulingana na hali hiyo (maandishi ya utafutaji na thamani ya kisanduku cha kuteua).
285269
* `SearchBar` inahitaji kuonyesha hali hiyo (maandishi ya utafutaji na thamani ya kisanduku cha kuteua).
286270
1. **Tafuta mzazi wao wa kawaida:** Kijenzi mzazi cha kwanza ambacho vijenzi vyote viwili hushiriki ni `FilterableProductTable`.
287271
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-
>>>>>>> 152a471aa9ac2f6f0f3e64c04f39da790d40cf61
297272

298273
Kwa hivyo state thamani zitaishi katika `FilterableProductTable`.
299274

@@ -481,16 +456,7 @@ function SearchBar({ filterText, inStockOnly }) {
481456
482457
Hata hivyo, bado hujaongeza msimbo wowote ili kujibu vitendo vya mtumiaji kama vile kuandika. Hii itakuwa hatua yako ya mwisho.
483458
484-
<<<<<<< HEAD
485459
## 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-
>>>>>>> 152a471aa9ac2f6f0f3e64c04f39da790d40cf61
494460
495461
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`:
496462

src/content/reference/react/Fragment.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ Wrap elements in `<Fragment>` to group them together in situations where you nee
3838

3939
* React does not [reset state](/learn/preserving-and-resetting-state) when you go from rendering `<><Child /></>` to `[<Child />]` or back, or when you go from rendering `<><Child /></>` to `<Child />` and back. This only works a single level deep: for example, going from `<><><Child /></></>` to `<Child />` resets the state. See the precise semantics [here.](https://gist.github.com/clemmy/b3ef00f9507909429d8aa0d3ee4f986b)
4040

41-
* <CanaryBadge /> If you want to pass `ref` to a Fragment, you can't use the `<>...</>` syntax. You have to explicitly import `Fragment` from `'react'` and render `<Fragment ref={yourRef}>...</Fragment>`.
41+
**Layout methods:**
42+
- `compareDocumentPosition(otherNode)`: Compares the document position of the Fragment with another node.
43+
- If the Fragment has children, the native `compareDocumentPosition` value is returned.
44+
- Empty Fragments will attempt to compare positioning within the React tree and include `Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC`.
45+
- Elements that have a different relationship in the React tree and DOM tree due to portaling or other insertions are `Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC`.
46+
- `getClientRects()`: Returns a flat array of `DOMRect` objects representing the bounding rectangles of all children.
47+
- `getRootNode()`: Returns the root node containing the Fragment's parent DOM node.
4248

4349
---
4450

@@ -759,12 +765,10 @@ function VisibleGroup({ onVisibilityChange, children }) {
759765
onVisibilityChange(visibleElements.size > 0);
760766
}
761767
);
762-
const fragmentInstance = fragmentRef.current;
763-
fragmentInstance.observeUsing(observer);
764-
return () => {
765-
fragmentInstance.unobserveUsing(observer);
766-
};
767-
}, [onVisibilityChange]);
768+
769+
fragmentRef.current.observeUsing(observer);
770+
return () => fragmentRef.current.unobserveUsing(observer);
771+
}, [threshold, onVisibilityChange]);
768772

769773
return (
770774
<Fragment ref={fragmentRef}>

src/content/reference/react/use.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,11 @@ function Albums() {
13321332
13331333
To fix this, cache the Promise so the same instance is reused:
13341334
1335-
```js
1336-
// ✅ fetchData returns the same Promise for the same URL
1337-
const albums = use(fetchData('/albums'));
1335+
```jsx
1336+
function MessageComponent({messagePromise}) {
1337+
// ✅ `use` is being called from a component.
1338+
const message = use(messagePromise);
1339+
// ...
13381340
```
13391341
13401342
See [caching Promises for Client Components](#caching-promises-for-client-components) for more details.

0 commit comments

Comments
 (0)