function Profile({ id }) {
  const [user, setUser] = useState(null);

  useEffect(() => {
    fetch(`/api/users/${id}`)
      .then((res) => res.json())
      .then(setUser);
  }, [id]);

  return <Card user={user} />;
}
1/3

Fetch the user in an effect

Code morph

Glides every surviving token to its new spot as a tutorial moves to the next step.

Cards & media
View source