Skip to content

Instantly share code, notes, and snippets.

@rayrayzayzay
Created July 18, 2022 23:16
Show Gist options
  • Save rayrayzayzay/295b52fa4153b1115f70c8c45de1b167 to your computer and use it in GitHub Desktop.
Save rayrayzayzay/295b52fa4153b1115f70c8c45de1b167 to your computer and use it in GitHub Desktop.
✅ A simpler component
function UserProfile({ request }:
{ request: UserProfileRequest }) {
switch (request.status) {
case "fetching":
return <Spinner />
case "success":
return <UserProfileCard user={request.data} />
case "error":
return (
<ErrorMessage
code={request.statusCode}
message={request.errorMessage}
/>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment