Getting Started with Suspense and Concurrent Rendering in React

Rate this content
Bookmark

React keeps on evolving and making hard things easier for the average developer.


One case, where React was not particularly hard but very repetitive, is working with AJAX request. There is always the trinity of loading, success and possible error states that had to be handled each time. But no more as the `<Suspense />` component makes life much easier.


Another case is performance of larger and complex applications. Usually React is fast enough but with a large application rendering components can conflict with user interactions. Concurrent rendering will, mostly automatically, take care of this.


You will learn all about using <Suspense />, showing loading indicators and handling errors. You will see how easy it is to get started with concurrent rendering. You will make suspense even more capable combining it with concurrent rendering, the `useTransition()` hook and the <SuspenseList /> component.

This workshop has been presented at React Summit 2020, check out the latest edition of this React Conference.

FAQ

The instructor for the React workshop is Maurice de Bayer, also known as the Problem Solver. He is a freelance developer and instructor.

The slides for the React workshop are available on GitHub, SlideShare, and Maurice de Bayer's website.

The main goals of the React workshop are to learn about using suspense and lazy loading, bundle splitting, using data resources to load data, and exploring concurrent rendering in React.

It is recommended to avoid copying and pasting code. Instead, type out the code, make mistakes, and fix them to learn and remember better.

The prerequisites for the React workshop include having Node.js and npm installed. The workshop is designed for experienced React developers.

React.lazy is used for bundle splitting in the workshop. It allows components to be loaded asynchronously, reducing the initial load time of the application.

React Suspense works by allowing components to suspend rendering while they wait for some asynchronous operation (like data fetching) to complete. It shows a fallback UI, like a loading spinner, until the operation is done.

Using data resources with React Suspense allows you to handle data fetching more efficiently by suspending the component until the data is available, making the code simpler and more maintainable.

Concurrent mode in React is an experimental feature that allows React to interrupt rendering work to handle more urgent updates, making applications more responsive.

New features available with React's concurrent mode include SuspenseList, useTransition, and more efficient interruptible rendering, which improve user experience and application performance.

Maurice de Beijer
Maurice de Beijer
125 min
15 Jul, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The workshop video delves into various techniques to optimize React applications, focusing on React Concurrent Mode and Suspense. It starts with an introduction to React.lazy for lazy loading components, which helps in bundle splitting and reduces initial load times. The use of Suspense in React allows for suspending component rendering until data is loaded, enhancing user experience. The video also covers suspense boundaries, which help in managing loading states and errors. Concurrent Mode is discussed in-depth, highlighting its benefits in improving application responsiveness by allowing interruptions in rendering for user interactions. The concept of preloading data on user interactions, like hovering over links, is also explored to make applications appear faster. Other key points include handling errors with error boundaries and using experimental features like the SuspenseList and useTransition hook for better UI control.
Video transcription and chapters available for users with access.