Designing All Four

The idea. Any interface that fetches something has four possible states, and an application that only designs the happy one looks broken during exactly the moments a person is most likely to give up on it.

Loading. It is working, and has not finished.

Error. It failed, and here is what to do next.

Empty. It worked and there is genuinely nothing. This is not an error.

Results. The one everybody builds first.

Empty is not error. A search with no matches has succeeded. Telling someone something went wrong when nothing went wrong sends them off to debug their own spelling, or their connection, instead of trying a different word.

An error state without a way forward is a dead end. Give it a retry button. The most common cause of a failed request is a network that has since come back.

◈ Graded Component

Build a component that renders exactly one of four states from props. Given props status and items, render a paragraph with id state whose text is: Loading when status is loading, Something went wrong when status is error, No results found when status is ok but items is empty, and N results when status is ok and items has entries. App is given to you and cycles the state with buttons.

Checked against what your component renders and how it responds, not against how you wrote it. 3 visible and 3 hidden checks.

loading editor…

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Practice Test →
← Back