Load a User Profile

Write the code, see it run, pass the checks.

The problem

  • easy
  • Code

Profile gets a fetchUser prop: a function that takes no arguments and returns a Promise of a user such as { name: "Ada Lovelace", email: "ada@example.com" }. When the component mounts, call fetchUser once. While you wait, show a paragraph reading "Loading..." (three full stops). When the user arrives, replace it with a heading showing the name and a paragraph showing the email. The starter's default fetchUser resolves after half a second, so the preview works; the checks pass their own.

Your code must pass

  • Shows "Loading..." while the user loads
  • Shows the name and email once they arrive
  • Calls fetchUser only once