diff --git a/content/docs/concurrent-mode-patterns.md b/content/docs/concurrent-mode-patterns.md index 98ec083ca..13003412b 100644 --- a/content/docs/concurrent-mode-patterns.md +++ b/content/docs/concurrent-mode-patterns.md @@ -1,6 +1,6 @@ --- id: concurrent-mode-patterns -title: Concurrent UI Patterns (Experimental) +title: Konkurrent UI Həlləri (Eksperimental) permalink: docs/concurrent-mode-patterns.html prev: concurrent-mode-suspense.html next: concurrent-mode-adoption.html @@ -15,63 +15,63 @@ next: concurrent-mode-adoption.html
+
-At the very end, we have the **Complete** state. That's where we want to eventually get to. It represents the moment when the next screen is fully rendered and isn't loading more data.
+Ən sonda **Tam** (Complete) vəziyyətinə çatırıq. Biz, ən axırda bu vəziyyətə çatmaq istəyirik. Bu, məlumatın artıq yükləndiyini və sonrakı ekranın tam render olunması halını təmsil edir.
-But before our screen can be Complete, we might need to load some data or code. When we're on the next screen, but some parts of it are still loading, we call that a **Skeleton** state.
+Lakin, ekran Tam olmamışdan öncə bizə bəzi məlumat və ya kodları yükləmək lazım ola bilər. Biz, sonrakı ekranda olunması və məlumatların tam yüklənməməsi vəziyyətini **Skelet** (Skeleton) adlandırırıq.
-Finally, there are two primary ways that lead us to the Skeleton state. We will illustrate the difference between them with a concrete example.
+Skelet vəziyyətinə çatmaq üçün iki əsas yol var. Biz bu iki yol arasında olan fərqləri nümunələr ilə göstərəcəyik.
-### Default: Receded → Skeleton → Complete {#default-receded-skeleton-complete}
+### Sadə: Qayıtmış → Skelet → Tam {#default-receded-skeleton-complete}
-Open [this example](https://codesandbox.io/s/prod-grass-g1lh5) and click "Open Profile". You will see several visual states one by one:
+[Bu nümunədə](https://codesandbox.io/s/prod-grass-g1lh5) "Open Profile" düyməsini tıklayın. Siz bir neçə vizual vəziyyətləri bir-bir görəcəksiniz:
-* **Receded**: For a second, you will see the `Loading...
` fallback until we get fresh results. This is not ideal. It would be better if we could see the *previous* translation for a bit while we're fetching the next one. +Anket sahəsinə mətn daxil etdikdə `Yüklənir...
` fallback-i göstərilir. Bu ideal deyil. Yeni məlumat yükləndiyi zaman *əvvəlki* tərcüməni görməyimiz daha faydalı ola bilər. -In fact, if we open the console, we'll see a warning: +Faktiki olaraq konsolu açdıqda aşağıdakı xəbərdarlığı görəcəyik: ``` Warning: App triggered a user-blocking update that suspended. @@ -672,7 +672,7 @@ The fix is to split the update into multiple parts: a user-blocking update to pr Refer to the documentation for useTransition to learn how to implement this pattern. ``` -As we mentioned earlier, if some state update causes a component to suspend, that state update should be wrapped in a transition. Let's add `useTransition` to our component: +Əvvəl qeyd etdiyimiz kimi yenilik zamanı komponent dayandırılırsa state yeniliyini keçid ilə əhatə etmək faydalıdır. Gəlin, komponentimizə `useTransition` əlavə edək: ```js{4-6,10,13} function App() { @@ -695,39 +695,39 @@ function App() { } ``` -**[Try it on CodeSandbox](https://codesandbox.io/s/zen-keldysh-rifos)** +**[CodeSandbox-da sınayın](https://codesandbox.io/s/zen-keldysh-rifos)** -Try typing into the input now. Something's wrong! The input is updating very slowly. +İndi, anket sahəsinə nəsə yazın. Nəsə səhv işləyir! Anket sahəsi çox gec yenilənir. -We've fixed the first problem (suspending outside of a transition). But now because of the transition, our state doesn't update immediately, and it can't "drive" a controlled input! +Biz birinci problemi həll etdik (keçid artıq yenilənmir). Amma, keçidə görə state, dərhal yenilənmədiyindən anket sahəsini idarə edə bilmir! -The answer to this problem **is to split the state in two parts:** a "high priority" part that updates immediately, and a "low priority" part that may wait for a transition. +Bunu həll etməyin yolu **state-i iki hissəyə parçalamaqdır:** dərhal yenilənən "yüksək prioritetli" hissə və keçidi gözləyən "aşağı prioritetli" hissə. -In our example, we already have two state variables. The input text is in `query`, and we read the translation from `resource`. We want changes to the `query` state to happen immediately, but changes to the `resource` (i.e. fetching a new translation) should trigger a transition. +Bizim nümunəmizdə artıq iki state dəyişəni var. Anket sahəsinin dəyəri `query` state-ində, tərcümə dəyəri isə `resource` dəyərində saxlanılır. Biz, `query` state-ində baş verən yenilikləri dərhal görmək, `resource` state-ində baş verən dəyişikliklərin isə (yəni yeni tərcümənin yüklənməsi) keçidi icra etməsini istəyirik. -So the correct fix is to put `setQuery` (which doesn't suspend) *outside* the transition, but `setResource` (which will suspend) *inside* of it. +Bunu həll etməyin düzgün yolu `setQuery` (dayandırılmayan) funksiyasını keçiddən *kənarda* çağırmaq, `setResource` (dayandırılan) funksiyasını isə keçidin *daxilindən* çağrımaqdır. ```js{4,5} function handleChange(e) { const value = e.target.value; - // Outside the transition (urgent) + // Keçiddən kənarda (təcili) setQuery(value); startTransition(() => { - // Inside the transition (may be delayed) + // Keçidin daxilində (gecikdirilə bilər) setResource(fetchTranslation(value)); }); } ``` -**[Try it on CodeSandbox](https://codesandbox.io/s/lively-smoke-fdf93)** +**[CodeSandbox-da sınayın](https://codesandbox.io/s/lively-smoke-fdf93)** -With this change, it works as expected. We can type into the input immediately, and the translation later "catches up" to what we have typed. +Bu dəyişiklik ilə davranış istədiyimiz kimi işləyir. Biz anket sahəsinə dərhal yaza bilirik və tərcümə məlumatları yazdığımız ilə sinxronizə olur. -### Deferring a Value {#deferring-a-value} +### Dəyəri Gecikdirmək {#deferring-a-value} -By default, React always renders a consistent UI. Consider code like this: +Normalda, React həmişə stabil UI render edir. Aşağıdakı koda baxın: ```js <> @@ -736,11 +736,11 @@ By default, React always renders a consistent UI. Consider code like this: > ``` -React guarantees that whenever we look at these components on the screen, they will reflect data from the same `user`. If a different `user` is passed down because of a state update, you would see them changing together. You can't ever record a screen and find a frame where they would show values from different `user`s. (If you ever run into a case like this, file a bug!) +React, ekrada gördüyümüz komponentlərin həmişə `user` məlumatını göstərəcəyini siğortalayır. State yenili nəticəsində komponentlərə fərqli `user` dəyəri göndərildikdə hər iki komponentin dəyişdiyini görəcəksiniz. Siz, ekranda fərqli `user` göstərən kadr tapa bilməzsiniz. (Bu problem ilə qarşılaşmısınızsa, bizə baq göndərin!) -This makes sense in the vast majority of situations. Inconsistent UI is confusing and can mislead users. (For example, it would be terrible if a messenger's Send button and the conversation picker pane "disagreed" about which thread is currently selected.) +Bu, bir çox halda məntiqlidir. Stabil olmayan UI, istifadəçiləri çaşdıra bilər. (Məsələn, messencerin "Göndər" düyməsi ilə danışıq seçici panel fərqli seçilmiş mövzu göstərdikdə çaşdırıcı ola bilər.) -However, sometimes it might be helpful to intentionally introduce an inconsistency. We could do it manually by "splitting" the state like above, but React also offers a built-in Hook for this: +Lakin, bəzən qəsdən stabilsizlik təqdim etmək faydalı ola bilər. Yuxarıdakı nümunədəki kimi state-i iki yerə "parçalayaraq" buna nail olmaq olar. Lakin, React-də bunun üçün hazır Hook var: ```js import { useDeferredValue } from 'react'; @@ -750,11 +750,11 @@ const deferredValue = useDeferredValue(value, { }); ``` -To demonstrate this feature, we'll use [the profile switcher example](https://codesandbox.io/s/musing-ramanujan-bgw2o). Click the "Next" button and notice how it takes 1 second to do a transition. +Bu xüsusiyyəti nümayiş edə bilmək üçün biz [profayl dəyişdirən nümunəsinə](https://codesandbox.io/s/musing-ramanujan-bgw2o) baxacağıq. "Sonrakı" düyməsini tıkladıqda keçidin 1 saniyə çəkdiyinə fikir verin. -Let's say that fetching the user details is very fast and only takes 300 milliseconds. Currently, we're waiting a whole second because we need both user details and posts to display a consistent profile page. But what if we want to show the details faster? +Fərz etdək ki, istifadəçi detallarının yüklənməsi çox tezdir (məsələn, 300ms). İndiki zamanda bizə həm istifadəçi detallarının, həm də yazıların hazır olması lazım olduğundan biz bir saniyə gözləyirik. Bəs biz istifadəçi detallarını tez göstərmək istəsək nə etməliyik? -If we're willing to sacrifice consistency, we could **pass potentially stale data to the components that delay our transition**. That's what `useDeferredValue()` lets us do: +Əgər stabilliyə fəda etmək istəyiriksə, biz **keçidləri gecikdirən komponentlərə köhnə məlumatlar göndərə bilərik**. `useDeferredValue()` ilə bunu etmək mümkündür: ```js{2-4,10,11,21} function ProfilePage({ resource }) { @@ -762,9 +762,9 @@ function ProfilePage({ resource }) { timeoutMs: 1000 }); return ( -