Upgrade to Pro — share decks privately, control downloads, hide ads and more …

meet.js Online #1

meet.js Online #1

What is React suspense and should we use it now?

Avatar for Patryk Omiotek

Patryk Omiotek

November 19, 2020

Other Decks in Programming

Transcript

  1. CO WIEMY O SUSPENSE? • Komponent pojawił się w wersji

    16.6 • Obszary wykorzystania: performance, data fetching • Nie nadaje się jeszcze do wykorzystania komercyjnego?
  2. We’ve build a generic way to ensure that high-priority updates

    like user input don’t get blocked by rendering low-priority-updates TIME SLICING
  3. TIME SLICING • React doesn’t block the thread while rendering

    • Feels synchronous if the device is fast • Feels responsive if the device is slow • Only the final rendered state is displayed • Declarative component model
  4. WHAT IS NOT? • Not a data fetching implementation •

    Not a ready-to-use client • Doesn’t couple data fetching to the view layer
  5. WHAT LETS YOU DO? • lets data fetching libraries deeply

    integrate with React • lets you orchestrate intentionally designed loading states • helps you avoid race conditions
  6. USING IN PRACTICE • Facebook uses Relay integration with Suspense

    in production • Over the next several months, many libraries will appear with different takes on Suspense APIs
  7. SUSPENSE We’ve build a generic way for components to suspend

    rendering while they load asynchronous data
  8. SUSPENSE • Pause any data update until the data is

    ready • Add async data to any component without “plumbing” • On a fast network, render after the whole tree is ready • On a slow network, precisely control the loading states • There’s both a high-level and low-level API
  9. TIME SLICING AND SUSPENSE With vast differences in computing power

    and network speed how do we deliver by the best user-experience for everyone
  10. ASYNC RENDERING WITH REACT • Adapt to user’s device and

    network • Fast interactions feel instant • Slower interactions feel sponsive
  11. CZEGO SIĘ DZISIAJ DOWIEDZIELIŚMY? • Suspense nie jest przeznaczony do

    produkcji • Umożliwia code splitting • Umożliwia inne podejście do pobierania danych