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
->Caution: +>Xəbərdarlıq: > ->This page describes **experimental features that are [not yet available](/docs/concurrent-mode-adoption.html) in a stable release**. Don't rely on experimental builds of React in production apps. These features may change significantly and without a warning before they become a part of React. +>Bu səhifədə **stabil buraxılışlarda [mövcud olmayan](/docs/concurrent-mode-adoption.html) eksperimental xüsusiyyətlərdən danışılır**. Produksiya applikasiyalarında eksperimental qurulmalardan istifadə etməyin. Buradakı xüsusiyyətlər React-in bir hissəsi olana kimi xəbərdarlıq verilmədən əhəmiyyətli dərəcədə dəyişilə bilər. > ->This documentation is aimed at early adopters and people who are curious. **If you're new to React, don't worry about these features** -- you don't need to learn them right now. For example, if you're looking for a data fetching tutorial that works today, read [this article](https://www.robinwieruch.de/react-hooks-fetch-data/) instead. +>Bu sənədlər erkən yoxlamaq istəyən və maraqlanan insanlar üçün yönəldilib. **Əgər React-ə yeni başlayırsınızsa, burada danışılan xüsusiyyətlərdən narahat olmayın** -- bu xüsusiyyətləri indi öyrənmək lazım deyil. Məsələn, əgər sizə bugün işləyən məlumat yüklənməsi dərsliyi lazımdırsa, [bu məqaləni](https://www.robinwieruch.de/react-hooks-fetch-data/) oxuyun.
-Usually, when we update the state, we expect to see changes on the screen immediately. This makes sense because we want to keep our app responsive to user input. However, there are cases where we might prefer to **defer an update from appearing on the screen**. - -For example, if we switch from one page to another, and none of the code or data for the next screen has loaded yet, it might be frustrating to immediately see a blank page with a loading indicator. We might prefer to stay longer on the previous screen. Implementing this pattern has historically been difficult in React. Concurrent Mode offers a new set of tools to do that. - -- [Transitions](#transitions) - - [Wrapping setState in a Transition](#wrapping-setstate-in-a-transition) - - [Adding a Pending Indicator](#adding-a-pending-indicator) - - [Reviewing the Changes](#reviewing-the-changes) - - [Where Does the Update Happen?](#where-does-the-update-happen) - - [Transitions Are Everywhere](#transitions-are-everywhere) - - [Baking Transitions Into the Design System](#baking-transitions-into-the-design-system) -- [The Three Steps](#the-three-steps) - - [Default: Receded → Skeleton → Complete](#default-receded-skeleton-complete) - - [Preferred: Pending → Skeleton → Complete](#preferred-pending-skeleton-complete) - - [Wrap Lazy Features in ``](#wrap-lazy-features-in-suspense) - - [Suspense Reveal “Train”](#suspense-reveal-train) - - [Delaying a Pending Indicator](#delaying-a-pending-indicator) - - [Recap](#recap) -- [Other Patterns](#other-patterns) - - [Splitting High and Low Priority State](#splitting-high-and-low-priority-state) - - [Deferring a Value](#deferring-a-value) +Adətən, state-i yenilədikdə dəyişiklikləri ekranda dərhal görmək istəyirik. Applikasiyanın istifadəçi daxil etməsini tez cavablandırmasını istədiyimizdən bu fikir məntiqli gəlir. Lakin, bəzi ssenarilərdə **yeniliyin ekranda görünməsini gecikdirmək istəyə bilərik**. + +Məsələn, bir səhifədən digər səhifəyə keçid etdiyimiz zaman yeni səhifəyə aid olan heç bir kod və ya məlumat yüklənmədiyi halda yükləmə göstəricisi ilə boş səhifənin görünməsi əsəbləşdirici ola bilər. Bu səbəbdən əvvəlki ekranda daha uzun qalmaq istəyə bilərik. Tarix boyu bu həllin React-də tətbiqi çətin olub. Lakin, bunu həll etmək üçün Konkurrent Moduna yeni alətlər əlavə olunub. + +- [Keçidlər](#transitions) + - [setState-i Keçid ilə Əhatə Etmək](#wrapping-setstate-in-a-transition) + - [Yükləmə Göstəricini Əlavə Etmək](#adding-a-pending-indicator) + - [Dəyişiklikləri Nəzərdən Keçirmək](#reviewing-the-changes) + - [Yeniliklər Harada Baş Verir?](#where-does-the-update-happen) + - [Keçidlər Hər Yerdədir](#transitions-are-everywhere) + - [Keçidləri Dizayn Sisteminə Əlavə Etmək](#baking-transitions-into-the-design-system) +- [Üç Addım](#the-three-steps) + - [Sadə: Qayıtmış → Skelet → Tam](#default-receded-skeleton-complete) + - [Üstünlük Verilən: Yükləmə → Skelet → Tam](#preferred-pending-skeleton-complete) + - [Lazy Xüsusiyyətləri `` ilə Əhatə Edin](#wrap-lazy-features-in-suspense) + - [Suspense-lərin Göstərilməsi “Qatarı”](#suspense-reveal-train) + - [Yükləmə Göstəricisini Gecikdirmək](#delaying-a-pending-indicator) + - [Xülasə](#recap) +- [Digər Həllər](#other-patterns) + - [Yüksək və Aşağı Priooritetli State-ləri Parçalamaq](#splitting-high-and-low-priority-state) + - [Dəyəri Gecikdirmək](#deferring-a-value) - [SuspenseList](#suspenselist) -- [Next Steps](#next-steps) +- [Sonrakı Addımlar](#next-steps) -## Transitions {#transitions} +## Keçidlər {#transitions} -Let's revisit [this demo](https://codesandbox.io/s/infallible-feather-xjtbu) from the previous page about [Suspense for Data Fetching](/docs/concurrent-mode-suspense.html). +Gəlin [Məlumat Yüklənməsi üçün Suspense]((/docs/concurrent-mode-suspense.html)) səhifəsindəki [nümunəyə](https://codesandbox.io/s/infallible-feather-xjtbu) yenidən baxaq. -When we click the "Next" button to switch the active profile, the existing page data immediately disappears, and we see the loading indicator for the whole page again. We can call this an "undesirable" loading state. **It would be nice if we could "skip" it and wait for some content to load before transitioning to the new screen.** +Aktiv profaylı dəyişmək üçün "Sonrakı" düyməsini tıkladıqda mövcud səhifənin məlumatları dərhal itir və biz bütün səhifə üçün yükləmə göstəricisini göstərilir. Biz bunu "istənilməz" yükləmə vəziyyəti adlandırırıq. **Yeni səhifəyə keçməmişdən öncə yükləmə göstəricisini göstərməyib bəzi kontentin yüklənməsini gözləmək daha yaxşı istifadəçi təcrübəsi yarada bilər.** -React offers a new built-in `useTransition()` Hook to help with this. +Bunu həll etmək üçün React-ə `useTransition()` adlı Hook əlavə etmişik. -We can use it in three steps. +Bu Hooku üç addım ilə işlətmək mümkündür. -First, we'll make sure that we're actually using Concurrent Mode. We'll talk more about [adopting Concurrent Mode](/docs/concurrent-mode-adoption.html) later, but for now it's sufficient to know that we need to use `ReactDOM.createRoot()` rather than `ReactDOM.render()` for this feature to work: +İlk olaraq Konkurrent Modunu işlətdiyimizi bilməliyik. Biz, [Konkurrent Moduna uyğunlaşma](/docs/concurrent-mode-adoption.html) haqqında sonrakı səhifələrdə danışacağıq, amma bu səhifədə bu xüsusiyyətin işləməsi üçün `ReactDOM.render()` əvəzinə `ReactDOM.createRoot()` işlətmək kifayət edir: ```js const rootElement = document.getElementById("root"); -// Opt into Concurrent Mode +// Konkurrent Modundan İstifadə Et ReactDOM.createRoot(rootElement).render(); ``` -Next, we'll add an import for the `useTransition` Hook from React: +Sonrakı səhifədə React-dən `useTransition` Hookunu idxal edəcəyik: ```js import React, { useState, useTransition, Suspense } from "react"; ``` -Finally, we'll use it inside the `App` component: +Ən sonda, bu Hooku `App` komponentində işlədəcəyik: ```js{3-5} function App() { @@ -82,18 +82,18 @@ function App() { // ... ``` -**By itself, this code doesn't do anything yet.** We will need to use this Hook's return values to set up our state transition. There are two values returned from `useTransition`: +**Bu funksiya təklikdə heç nə etmir.** Biz, bu Hookun qaytardığı dəyərlər əsasında state keçidini quraşdırmalıyıq. `useTransition` Hooku iki dəyər qaytarır: -* `startTransition` is a function. We'll use it to tell React *which* state update we want to defer. -* `isPending` is a boolean. It's React telling us whether that transition is ongoing at the moment. +* `startTransition` funksiyadır. Bu funksiya ilə *hansı* state yeniliyini təxirə salmaq istədiyimizi bildirəcəyik. +* `isPending` bulin dəyərdir. Bu dəyər keçidin proqresdə olduğunu bildirir. -We will use them right below. +Biz, bu iki dəyəri aşağı bölmədə işlədəyəcik. -Note we passed a configuration object to `useTransition`. Its `timeoutMs` property specifies **how long we're willing to wait for the transition to finish**. By passing `{timeoutMs: 3000}`, we say "If the next profile takes more than 3 seconds to load, show the big spinner -- but before that timeout it's okay to keep showing the previous screen". +`useTransition` Hookuna konfiqurasiya obyekti göndərdiyimizə fikir verin. `timeoutMs` parametri **keçidin bitməsi üçün nə qədər gözləməyin lazım olduğunu** təyin edir. Məsələn, `{timeoutMs: 3000}` obyekti göndərdikdə "sonrakı profaylın yüklənməsi 3 saniyədən çox çəkdikdə böyük spinner-i göstərməyi, əks halda isə cari ekranda olan məlumatları göstərməyi" bildiririk. -### Wrapping setState in a Transition {#wrapping-setstate-in-a-transition} +### setState-i Keçid ilə Əhatə Etmək {#wrapping-setstate-in-a-transition} -Our "Next" button click handler sets the state that switches the current profile in the state: +"Sonrakı" düyməsinin hadisə işləyicisi cari profaylı dəyişmək üçün state-i yeniləyir: ```js{4} - {isPending ? " Loading..." : null} + {isPending ? " Yüklənir..." : null} ); ``` -**[Try it on CodeSandbox](https://codesandbox.io/s/jovial-lalande-26yep)** +**[CodeSandbox-da sınayın](https://codesandbox.io/s/jovial-lalande-26yep)** -Now, this feels a lot better! When we click Next, it gets disabled because clicking it multiple times doesn't make sense. And the new "Loading..." tells the user that the app didn't freeze. +İndi daha yaxşı oldu! "Sonrakı" düyməsini tıkladıqda düymənin bir neçə dəfə tıklanmaması üçün bu düyməni deaktivasiya edirik. Yeni "Yüklənir..." yazısı ilə də istifadəçiyə applikasiyanın donmadığını bildiririk. -### Reviewing the Changes {#reviewing-the-changes} +### Dəyişiklikləri Nəzərdən Keçirmək {#reviewing-the-changes} -Let's take another look at all the changes we've made since the [original example](https://codesandbox.io/s/infallible-feather-xjtbu): +Gəlin, [orijinal nümunədən](https://codesandbox.io/s/infallible-feather-xjtbu) buraya kimi hansı dəyişikliklərin edildiyini nəzərdən keçirək: ```js{3-5,9,11,14,19} function App() { @@ -180,49 +180,49 @@ function App() { }); }} > - Next + Sonrakı - {isPending ? " Loading..." : null} + {isPending ? " Yüklənir..." : null} ); } ``` -**[Try it on CodeSandbox](https://codesandbox.io/s/jovial-lalande-26yep)** +**[CodeSandbox-da sınayın](https://codesandbox.io/s/jovial-lalande-26yep)** -It took us only seven lines of code to add this transition: +Bu keçidi əlavə etmək üçün yalnız yeddi sətir kod əlavə etdik: -* We've imported the `useTransition` Hook and used it the component that updates the state. -* We've passed `{timeoutMs: 3000}` to stay on the previous screen for at most 3 seconds. -* We've wrapped our state update into `startTransition` to tell React it's okay to delay it. -* We're using `isPending` to communicate the state transition progress to the user and to disable the button. +* `useTransition` Hookunu idxal edərək state-i yeniləyən komponentdə işlətdik. +* `{timeoutMs: 3000}` obyektini göndərərək React-ə cari ekranda ən çox üç saniyə gözləməsini bildirdik. +* State yeniliklərini `startTransition` ilə əhatə edərək React-ə bu yeniliyi gecikdirməyin problem olmadığını bildirdik. +* `isPending`-dən istifadə edəcərək state keçidinin proqresdə olduğunu bildirdik və düyməni deaktivasiya etdik. -As a result, clicking "Next" doesn't perform an immediate state transition to an "undesirable" loading state, but instead stays on the previous screen and communicates progress there. +Nəticədə, "Sonrakı" düyməni tıkladıqda "istənilməz" yükləmə vəziyyətinə dərhal keçid edilmir. Əvəzinə, proqres cari ekranda qalaraq göstərilir. -### Where Does the Update Happen? {#where-does-the-update-happen} +### Yeniliklər Harada Baş Verir? {#where-does-the-update-happen} -This wasn't very difficult to implement. However, if you start thinking about how this could possibly work, it might become a little mindbending. If we set the state, how come we don't see the result right away? *Where* is the next `` rendering? +Bunun tətbiqi heç də çətin deyildi. Lakin, bunun necə işlədiyini fikirləşdikdə biraz çaşdırıcı ola bilər. State-i təyin etdikdə nəticəni niyə dərhal görmürük? Sonrakı `` *harada* render olunur? -Clearly, both "versions" of `` exist at the same time. We know the old one exists because we see it on the screen and even display a progress indicator on it. And we know the new version also exists *somewhere*, because it's the one that we're waiting for! +Aydındır ki, ``-in hər iki "versiyası" eyni zamanda mövcuddur. Əvvəlki səhifəni gördüyümüzdən və hətta burada proqres göstəricisi göstərdiyimizdən bu səhifənin mövcud olduğunu bilirik. Yeni versiyanı gözlədiyimizdən bu versiyanın *mövcud* olduğunu bilirik! -**But how can two versions of the same component exist at the same time?** +**Eyni komponentin hər iki versiyası eyni zamanda necə mövcud ola bilər?** -This gets at the root of what Concurrent Mode is. We've [previously said](/docs/concurrent-mode-intro.html#intentional-loading-sequences) it's a bit like React working on state update on a "branch". Another way we can conceptualize is that wrapping a state update in `startTransition` begins rendering it *"in a different universe"*, much like in science fiction movies. We don't "see" that universe directly -- but we can get a signal from it that tells us something is happening (`isPending`). When the update is ready, our "universes" merge back together, and we see the result on the screen! +Bu Konkurrent Modun əsasıdır. Biz, [əvvəlki bölmədə dediyimiz kimi](/docs/concurrent-mode-intro.html#intentional-loading-sequences) bu, React-in state yeniliyinin fərqli "budaqda" işləməsinə bənzəyir. Bunu fərqli formada konseptuallaşdırmaq üçün `startTransition` ilə əhatə olunmuş state yeniliyinin *"fərqli dünyada"* (elmi fantastika filmlərində olduğu kimi) render edildiyini fikirləşin. Biz, bu dünyanı birbaşa "görə" bilmirik, amma bu dünyada nəyinsə baş verdiyinin siqnalını (`isPending`) ala bilirik. Yenilik hazır olduqda "dünyalar" birləşir və biz nəticəni ekranda görürük! -Play a bit more with the [demo](https://codesandbox.io/s/jovial-lalande-26yep), and try to imagine it happening. +Göstərilən [nümunə](https://codesandbox.io/s/jovial-lalande-26yep) ilə oynayıb bunun baş verdiyini təsəvvür edin. -Of course, two versions of the tree rendering *at the same time* is an illusion, just like the idea that all programs run on your computer at the same time is an illusion. An operating system switches between different applications very fast. Similarly, React can switch between the version of the tree you see on the screen and the version that it's "preparing" to show next. +Əlbəttə ki, kompyuterinizdə bütün proqramların eyni zamanda icra olunmasının illüziya olduğu kimi ağacın hər iki versiyasının *eyni zamanda* render edilməsi də illüziyadır. Əməliyyat sistemi fərqli applikasiyalar arasında çox tez keçidlər edir. Eyni formada, React də ekranda gördüyünüz ağac ilə "hazırlanan" sonrakı ağac arasında keçidlər edir. -An API like `useTransition` lets you focus on the desired user experience, and not think about the mechanics of how it's implemented. Still, it can be a helpful metaphor to imagine that updates wrapped in `startTransition` happen "on a branch" or "in a different world". +`useTransition` kimi API ilə bu mexanizmin necə tətbiq olunduğu haqqında fikirləşmək əvəzinə istifadəçi təcübəsinə fokuslana bilərsiniz. Amma yenə də, `startTransition` ilə əhatə olunan yeniliklərin digər "budaq" və ya "dünyada" olduğunu fikirləşmək faydalı ola bilər. -### Transitions Are Everywhere {#transitions-are-everywhere} +### Keçidlər Hər Yerdədir {#transitions-are-everywhere} -As we learned from the [Suspense walkthrough](/docs/concurrent-mode-suspense.html), any component can "suspend" any time if some data it needs is not ready yet. We can strategically place `` boundaries in different parts of the tree to handle this, but it won't always be enough. +[Suspense sənədində](/docs/concurrent-mode-suspense.html) öyrəndiyimiz kimi gözlənilən məlumatı hazır olmayan istənilən komponent "dayandırıla" bilər. Biz, ağacın fərqli yerlərində `` sərhədləri əlavə edərək bunu dəstəkləyə bilərik. Lakin, bu həmişə bəs olmaya bilər. -Let's get back to our [first Suspense demo](https://codesandbox.io/s/frosty-hermann-bztrp) where there was just one profile. Currently, it fetches the data only once. We'll add a "Refresh" button to check for server updates. +Gəlin, bir profayl olan [Suspense nümunəsinə](https://codesandbox.io/s/frosty-hermann-bztrp) qayıdaq. İndi, bu nümunədə məlumat bir dəfə yüklənir. Server yeniliklərini yoxlamaq üçün "Yenidən Yüklə" düyməsi əlavə edəcəyik. -Our first attempt might look like this: +İlk cəhdimiz belə ola bilər: ```js{6-8,13-15} const initialResource = fetchUserAndPosts(); @@ -235,12 +235,12 @@ function ProfilePage() { } return ( - Loading profile...}> + Profayl yüklənir...}> - Loading posts...}> + Yazılar yüklənir...}> @@ -248,18 +248,18 @@ function ProfilePage() { } ``` -**[Try it on CodeSandbox](https://codesandbox.io/s/boring-shadow-100tf)** +**[CodeSandbox-da sınayın](https://codesandbox.io/s/boring-shadow-100tf)** -In this example, we start data fetching at the load *and* every time you press "Refresh". We put the result of calling `fetchUserAndPosts()` into state so that components below can start reading the new data from the request we just kicked off. +Bu nümunədə, biz yükləmə zamanı *və* "Yenidən Yüklə" tıklandığı zaman məlumat yükləməsini başladırıq. Suspense-in altında olan komponentlərin yeni məlumatı oxuya bilmələri üçün `fetchUserAndPosts()` funksiyasının nəticəsini state-də saxlayırıq. -We can see in [this example](https://codesandbox.io/s/boring-shadow-100tf) that pressing "Refresh" works. The `` and `` components receive a new `resource` prop that represents the fresh data, they "suspend" because we don't have a response yet, and we see the fallbacks. When the response loads, we can see the updated posts (our fake API adds them every 3 seconds). +[Bu nümunədə](https://codesandbox.io/s/boring-shadow-100tf) "Yenidən Yüklə" düyməsinin işlədiyini görürük. `` və `` komponentləri yeni məlumatı təmsil edən yeni `resource` propunu qəbul edir və nəticə olmadığı zaman "dayandırılırlar" (fallback göstərilir). Cavab yükləndiyi zaman yenilənən yazıları görürük (saxta API bu nəticələri 3 saniyədən bir əlavə edir). -However, the experience feels really jarring. We were browsing a page, but it got replaced by a loading state right as we were interacting with it. It's disorienting. **Just like before, to avoid showing an undesirable loading state, we can wrap the state update in a transition:** +Lakin, istifadəçi təcrübəsi çox pisdir. Biz səhifəni gəzdiyimiz zaman bu səhifə yükləmə vəziyyətinə dəyişdi (elə bilki bu səhifə ilə interaksiya edirdik). Bu çaşdırıcıdır. **Əvvəki variantlarda olduğu kimi istənilməz yükləmə vəziyyətini görməmək üçün biz state yeniliyini keçid ilə əhatə edəcəyik:** ```js{2-5,9-11,21} function ProfilePage() { const [startTransition, isPending] = useTransition({ - // Wait 10 seconds before fallback + // Fallback-dən əvvəl 10 saniyə gözlə timeoutMs: 10000 }); const [resource, setResource] = useState(initialResource); @@ -271,15 +271,15 @@ function ProfilePage() { } return ( - Loading profile...}> + Profayl yüklənir...}> - Loading posts...}> + Yazılar yüklənir...}> @@ -287,15 +287,15 @@ function ProfilePage() { } ``` -**[Try it on CodeSandbox](https://codesandbox.io/s/sleepy-field-mohzb)** +**[CodeSandbox-da sınayın](https://codesandbox.io/s/sleepy-field-mohzb)** -This feels a lot better! Clicking "Refresh" doesn't pull us away from the page we're browsing anymore. We see something is loading "inline", and when the data is ready, it's displayed. +Bu daha yaxşı oldu! İndi, "Yenidən Yüklə" düyməsi tıklandıqda səhifədən dəyişmir. Nəyinsə yükləndiyi "sətrdaxili" göstərilir. Yeni məlumatlar yalnız hazır olduqda göstərilir. -### Baking Transitions Into the Design System {#baking-transitions-into-the-design-system} +### Keçidləri Dizayn Sisteminə Əlavə Etmək {#baking-transitions-into-the-design-system} -We can now see that the need for `useTransition` is *very* common. Pretty much any button click or interaction that can lead to a component suspending needs to be wrapped in `useTransition` to avoid accidentally hiding something the user is interacting with. +İndi, `useTransition`-a ehtiyacın *çox* olduğunu görə bilərsiniz. İstifadəçinin interaksiya etdiyi elementi təsadüfən gizlətməmək üçün komponenti dayandıra bilən hər hansı bir düymə və interaksiyanı `useTransition` ilə əhatə etmək lazımdır. -This can lead to a lot of repetitive code across components. This is why **we generally recommend to bake `useTransition` into the *design system* components of your app**. For example, we can extract the transition logic into our own ` - Loading posts...}> + Yazılar yüklənir...}> @@ -353,50 +353,50 @@ function ProfilePage() { } ``` -**[Try it on CodeSandbox](https://codesandbox.io/s/modest-ritchie-iufrh)** +**[CodeSandbox-da sınayın](https://codesandbox.io/s/modest-ritchie-iufrh)** -When a button gets clicked, it starts a transition and calls `props.onClick()` inside of it -- which triggers `handleRefreshClick` in the `` component. We start fetching the fresh data, but it doesn't trigger a fallback because we're inside a transition, and the 10 second timeout specified in the `useTransition` call hasn't passed yet. While a transition is pending, the button displays an inline loading indicator. +Düymə tıklandıqda keçid başlanır və daxilindən `props.onClick()` çağrılır. Bu callback, `` komponentində `handleRefreshClick` funksiyasını çağırır. Biz, yeni məlumatı yükləməyə başlayırıq, amma keçidin daxilində olduğumuzdan və `useTransition`-a göndərilən 10 saniyə bitmədiyindən fallback göstərilmir. Keçidin proqresdə olduğundan düymədə sətrdaxili yüklənmə göstəricisi göstərilir. -We can see now how Concurrent Mode helps us achieve a good user experience without sacrificing isolation and modularity of components. React coordinates the transition. +Konkurrent Modunun komponentlərin izolyasiyasını və modulyarlığını itirmədən yaxşı istifadəçi təcrübəsi yaratdığını görə bilərik. React keçidləri koordinasiya edir. -## The Three Steps {#the-three-steps} +## Üç Addım {#the-three-steps} -By now we have discussed all of the different visual states that an update may go through. In this section, we will give them names and talk about the progression between them. +Biz yeniliyin keçdiyi vizual vəziyyətlərdən danışdıq. Bu bölmədə bu vəziyyətlərə ad verib aralarındakı irəliləmələrdən danışacağıq.
-Three steps +Üç addım -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 the app...

` fallback. -* **Skeleton:** You will see the `` component with `

Loading posts...

` inside. -* **Complete:** You will see the `` component with no fallbacks inside. Everything was fetched. +* **Qayıtmış** (Receded): Çox qısa anlıq `

Loading the app...

` görünüşünü görəcəksiniz. +* **Skelet:** `` komponentini `

Loading posts...

` görünüşü ilə görəcəksiniz. +* **Tam:** Fallback-i olmayan `` komponentini görəcəksiniz. Burada bütün məlumatlar yüklənir. -How do we separate the Receded and the Skeleton states? The difference between them is that the **Receded** state feels like "taking a step back" to the user, while the **Skeleton** state feels like "taking a step forward" in our progress to show more content. +Qayıtmış və Skelet vəziyyətlərini necə ayırmaq olar? **Qayıtmış** vəziyyətində istifadəçinin "bir addım arxaya" getdiyi hiss olunur. **Skelet** vəziyyətində isə daha çox kontent göstərmək üçün istifadəçinin "bir addım irəliyə" getdiyi hiss olunur. -In this example, we started our journey on the ``: +Bu nümunədə biz `` komponentindən başlayırıq: ```js - {/* previous screen */} + {/* əvvəlki ekran */} ``` -After the click, React started rendering the next screen: +Düyməni tıkladıqdan sonra React sonrakı ekranı render etməyə başlayacaq: ```js - {/* next screen */} + {/* sonrakı ekran */} @@ -406,30 +406,30 @@ After the click, React started rendering the next screen: ``` -Both `` and `` need data to render, so they suspend: +Həm ``, həm də `` komponentlərinin render olunması üçün məlumat lazımdır. Bu səbəbdən bu komponentlər dayandırılırlar: ```js{4,6} - {/* next screen */} + {/* sonrakı ekran */} - {/* suspends! */} - Loading posts...}> - {/* suspends! */} + {/* dayandırılır! */} + Yazılar yüklənir...}> + {/* dayandırılır! */} ``` -When a component suspends, React needs to show the closest fallback. But the closest fallback to `` is at the top level: +Komponent dayandırıldıqdan sonra ən yaxın fallback göstəriləcək. Amma, `` komponentinə ən yaxın fallback ən yuxarı səviyyədədir: ```js{2,3,7} -

Loading the app...

+ // komponentinə görə burada fallback görəcəyik +

Applikasiya yüklənir...

}> - {/* next screen */} + {/* sonrakı ekran */} - {/* suspends! */} + {/* dayandırılır! */} @@ -437,52 +437,52 @@ When a component suspends, React needs to show the closest fallback. But the clo
``` -This is why when we click the button, it feels like we've "taken a step back". The `` boundary which was previously showing useful content (``) had to "recede" to showing the fallback (`

Loading the app...

`). We call that a **Receded** state. +Bu səbəbdən düyməni tıkladıqda "bir addım geriyə getdiyimizi" hiss edirik. Əvvəl faydalı kontent (``) göstərən `` sərhədi `

Applikasiya yüklənir...

` fallback-inə "qayıtmağa" məcbur oldu. Biz bu addımı **Qayıtmış** vəziyyət adlandırırıq. -As we load more data, React will retry rendering, and `` can render successfully. Finally, we're in the **Skeleton** state. We see the new page with missing parts: +Məlumat yükləndikcə React render etməni təkrar edəcək və `` komponenti uğurla render ediləcək. İndi, biz **Skelet** vəziyyətinə çataraq əskik hissəli səhifə görürük: ```js{6,7,9} - {/* next screen */} + {/* sonrakı ekran */} -

Loading posts...

+ // komponentinə görə bu fallback-i görürük +

Yazılar yüklənir...

}> - {/* suspends! */} + {/* dayandırılır! */}
``` -Eventually, they load too, and we get to the **Complete** state. +Ən axırda, hər iki komponent yüklənir və biz **Tam** vəziyyətinə çatırıq. -This scenario (Receded → Skeleton → Complete) is the default one. However, the Receded state is not very pleasant because it "hides" existing information. This is why React lets us opt into a different sequence (**Pending** → Skeleton → Complete) with `useTransition`. +Bu (Qayıtmış → Skelet → Tam) standart ssenaridir. Lakin, Qayıtmış vəziyyətin mövcud məlumatları "gizlətdiyindən" bu vəziyyət xoş deyil. Bu səbəbdən React bizə `useTransition` Hookundan istifadə edərək fərqli ardıcıllıqdan (**Yükləmə** → Skelet → Tam) istifadə etməyə imkan yaradır. -### Preferred: Pending → Skeleton → Complete {#preferred-pending-skeleton-complete} +### Üstünlük Verilən: Yükləmə → Skelet → Tam {#preferred-pending-skeleton-complete} -When we `useTransition`, React will let us "stay" on the previous screen -- and show a progress indicator there. We call that a **Pending** state. It feels much better than the Receded state because none of our existing content disappears, and the page stays interactive. +`useTransition` işlətdikdə biz köhnə səhifədə "qalıb" proqres göstərici göstərə bilirik. Biz bu addımı **Yükləmə** (Pending) vəziyyəti adlandırırıq. Mövcud kontentin itmədiyindən və səhifənin interaktiv qaldığından bu vəziyyət Qayıtmış vəziyyətindən daha yaxşıdır. -You can compare these two examples to feel the difference: +Bu vəziyyətlərin fərqini görmək üçün aşağıdakı nümunələri müqayisə edin: -* Default: [Receded → Skeleton → Complete](https://codesandbox.io/s/prod-grass-g1lh5) -* **Preferred: [Pending → Skeleton → Complete](https://codesandbox.io/s/focused-snow-xbkvl)** +* Sadə: [Qayıtmış → Skelet → Tam](https://codesandbox.io/s/prod-grass-g1lh5) +* **Üstünlük Verilən: [Yükləmə → Skelet → Tam](https://codesandbox.io/s/focused-snow-xbkvl)** -The only difference between these two examples is that the first uses regular `