You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/editor-setup.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,11 @@ Baadhi ya vihariri huja na maumbile haya yakiwa yamejengwa ndani, lakini vingine
31
31
32
32
### Linting {/*linting*/}
33
33
34
+
<<<<<<< HEAD
34
35
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
+
>>>>>>> 7b6c3ceb9dd97249e9dce4a8a94e61aed6424698
35
39
36
40
*[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/))
37
41
*[Unganisha ESLint katika VSCode na kiendelezi rasmi](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
Copy file name to clipboardExpand all lines: src/content/learn/thinking-in-react.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,9 +37,15 @@ Anza kwa kuchora visanduku kuzunguka kila kijenzi na kijenzi kidogo kwenye kiigi
37
37
38
38
Kulingana na msingi wako, unaweza kufikiria kugawanya muundo katika vijenzi kwa njia tofauti:
39
39
40
+
<<<<<<< HEAD
40
41
***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.
41
42
***CSS**--fikiria ni nini ungetengeneza viteule vya darasa. (Hatahivyo, vijenzi ni vidogo kwa kiasi fulani.)
42
43
***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
+
>>>>>>> 7b6c3ceb9dd97249e9dce4a8a94e61aed6424698
43
49
44
50
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.
45
51
@@ -226,10 +232,19 @@ Kilichobaki labda ni hali.
226
232
227
233
Wacha tupitie moja baada ya nyingine tena:
228
234
235
+
<<<<<<< HEAD
229
236
1. Orodha asili ya bidhaa **imepitishwa kama vifaa, kwa hivyo haijabainishwa.**
230
237
2. Maandishi ya utafutaji yanaonekana kuwa ya hali kwani yanabadilika kwa wakati na hayawezi kukokotwa kutoka kwa chochote.
231
238
3. Thamani ya kisanduku cha kuteua inaonekana kuwa hali kwani inabadilika kwa wakati na haiwezi kukokotwa kutoka kwa chochote.
232
239
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
+
>>>>>>> 7b6c3ceb9dd97249e9dce4a8a94e61aed6424698
233
248
234
249
Hii ina maana kwamba ni maandishi ya utafutaji pekee na thamani ya kisanduku cha kuteua ndizo zilizotajwa! Imefanywa vizuri!
235
250
<DeepDive>
@@ -262,13 +277,23 @@ In the previous step, you found two pieces of state in this application: the sea
262
277
263
278
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.
264
279
280
+
<<<<<<< HEAD
265
281
Sasa wacha tupitie mkakati wetu kwao:
266
282
267
283
1.**Tambua vijenzi vinavyotumia hali:**
268
284
*`ProductTable` inahitaji kuchuja orodha ya bidhaa kulingana na hali hiyo (maandishi ya utafutaji na thamani ya kisanduku cha kuteua).
269
285
*`SearchBar` inahitaji kuonyesha hali hiyo (maandishi ya utafutaji na thamani ya kisanduku cha kuteua).
270
286
1.**Tafuta mzazi wao wa kawaida:** Kijenzi mzazi cha kwanza ambacho vijenzi vyote viwili hushiriki ni `FilterableProductTable`.
271
287
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
+
>>>>>>> 7b6c3ceb9dd97249e9dce4a8a94e61aed6424698
272
297
273
298
Kwa hivyo state thamani zitaishi katika `FilterableProductTable`.
274
299
@@ -456,7 +481,16 @@ function SearchBar({ filterText, inStockOnly }) {
456
481
457
482
Hata hivyo, bado hujaongeza msimbo wowote ili kujibu vitendo vya mtumiaji kama vile kuandika. Hii itakuwa hatua yako ya mwisho.
458
483
484
+
<<<<<<< HEAD
459
485
## 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
+
>>>>>>> 7b6c3ceb9dd97249e9dce4a8a94e61aed6424698
460
494
461
495
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`:
Copy file name to clipboardExpand all lines: src/content/learn/tutorial-tic-tac-toe.md
-5Lines changed: 0 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -906,11 +906,6 @@ React DevTools hukuruhusu kuangalia *props* na *state* za vipengele vyako vya Re
906
906
Ili kuchunguza kipengele fulani kwenye skrini, tumia kitufe kilicho kwenye kona ya juu kushoto ya React DevTools:
907
907
908
908

909
-
After you install it, a new *Components* tab will appear in your browser Developer Tools for sites using React. If you're following along in CodeSandbox, you'd need to first open your sandbox preview in a new tab:
910
-
911
-

912
-
913
-
Then, on the preview page, open your browser's DevTools and find the *Components* tab:
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/server/renderToPipeableStream.md
+1-11Lines changed: 1 addition & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -284,17 +284,7 @@ Streaming does not need to wait for React itself to load in the browser, or for
284
284
285
285
<Note>
286
286
287
-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
288
-
289
-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
290
-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
291
-
- Reading the value of a Promise with [`use`](/reference/react/use)
292
-
293
-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
294
-
295
-
The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
296
-
297
-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
287
+
Only data read from a source that [activates a Suspense boundary](/reference/react/Suspense#what-activates-a-suspense-boundary), such as a Promise read with [`use`](/reference/react/use), will suspend during rendering. Suspense does not detect data fetched inside an Effect or event handler.
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/server/renderToReadableStream.md
+1-11Lines changed: 1 addition & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -283,17 +283,7 @@ Streaming does not need to wait for React itself to load in the browser, or for
283
283
284
284
<Note>
285
285
286
-
**Only Suspense-enabled data sources will activate the Suspense component.** They include:
287
-
288
-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/getting-started/react-essentials)
289
-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
290
-
- Reading the value of a Promise with [`use`](/reference/react/use)
291
-
292
-
Suspense **does not** detect when data is fetched inside an Effect or event handler.
293
-
294
-
The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
295
-
296
-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
286
+
Only data read from a source that [activates a Suspense boundary](/reference/react/Suspense#what-activates-a-suspense-boundary), such as a Promise read with [`use`](/reference/react/use), will suspend during rendering. Suspense does not detect data fetched inside an Effect or event handler.
Copy file name to clipboardExpand all lines: src/content/reference/react/Activity.md
+1-11Lines changed: 1 addition & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -755,17 +755,7 @@ Pre-rendering components with hidden Activity boundaries is a powerful way to re
755
755
756
756
<Note>
757
757
758
-
**Only Suspense-enabled data sources will be fetched during pre-rendering.** They include:
759
-
760
-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense)
761
-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
762
-
- Reading the value of a cached Promise with [`use`](/reference/react/use)
763
-
764
-
Activity **does not** detect data that is fetched inside an Effect.
765
-
766
-
The exact way you would load data in the `Posts` component above depends on your framework. If you use a Suspense-enabled framework, you'll find the details in its data fetching documentation.
767
-
768
-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official API for integrating data sources with Suspense will be released in a future version of React.
758
+
Only data read from a source that [activates a Suspense boundary](/reference/react/Suspense#what-activates-a-suspense-boundary), such as a Promise read with [`use`](/reference/react/use), is fetched during pre-rendering. Activity does not detect data fetched inside an Effect.
Copy file name to clipboardExpand all lines: src/content/reference/react/Fragment.md
+7-11Lines changed: 7 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,13 +38,7 @@ Wrap elements in `<Fragment>` to group them together in situations where you nee
38
38
39
39
* 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)
40
40
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.
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>`.
48
42
49
43
---
50
44
@@ -765,10 +759,12 @@ function VisibleGroup({ onVisibilityChange, children }) {
Copy file name to clipboardExpand all lines: src/content/reference/react/Suspense.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -286,7 +286,17 @@ import { fetchData } from './data.js';
286
286
exportdefaultfunctionEffectAlbums({ artistId }) {
287
287
const [albums, setAlbums] =useState([]);
288
288
289
-
Suspense-enabled data fetching without the use of an opinionated framework is not yet supported. The requirements for implementing a Suspense-enabled data source are unstable and undocumented. An official APIfor integrating data sources with Suspense will be released in a future version of React.
289
+
useEffect(() => {
290
+
let active =true;
291
+
fetchData(`/${artistId}/albums`).then(result=> {
292
+
if (active) {
293
+
setAlbums(result);
294
+
}
295
+
});
296
+
return () => {
297
+
active =false;
298
+
};
299
+
}, [artistId]);
290
300
291
301
// Suspense can't see this fetch, so its fallback never
292
302
// shows. The list stays empty until the data arrives.
0 commit comments