Loading tutorials
use, a function that reads a value from a resource while a component renders. The resource can be a promise or a context. This chapter explains what use does, how it differs from useContext, useState, and useEffect, and which rules apply to it. Later chapters cover the detai9 min readuse API can read a promise during render, but it has no way to show a loading state by itself. When the promise is still pending, use hands control to Suspense. A Suspense boundary is the component that decides what the user sees while they wait.7 min readuse API: reading the result of a promise while a component renders. By the end you should be able to write a component that waits for data, explain what React does while it waits, and recognize the mistakes that make this pattern misbehave.7 min readuseState and useContext, and that you know what a Suspense boundary is. It does not use promises. Those are covered in the neighbouring chapters, and here the focus is context.7 min readuseState and useContext, and read basic promise code (then, catch, async/await). It also assumes you know what a Suspense boundary does. The earlier chapters showed that use reads a promise during render and suspe8 min readuse API reads a promise during render. React can only do this safely if each render hands it the same promise object. This chapter explains what goes wrong when the promise changes between renders and the patterns that keep it stable.8 min readuse. The server then sends the rest of the page right away. The data follows when it is ready. This chapter covers how that works, what the promise looks like on the client, and t9 min readuse reads a promise and a context, how Suspense and error boundaries react to a suspended or failed component, and why a promise must keep the same identity across renders. You should also know the differ9 min read