
Lesson 08 · 12 min
Data from a server
Fetch in an effect. While loading — a separate state. An error is a state too, not an alert.
A typical screen: idle | loading | error | ready. When id changes, the effect downloads JSON. While waiting — a skeleton or "loading". The request failed — an error message and a retry button. Don't put fetch in the component body: every render goes to the network.
Sign in to continue
The rest of this lesson opens after sign up
The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.