Skip to content

Instantly share code, notes, and snippets.

@rayrayzayzay
Created July 18, 2022 23:15
Show Gist options
  • Save rayrayzayzay/8371fec80c6ec2fa5a4ebd93966d4dff to your computer and use it in GitHub Desktop.
Save rayrayzayzay/8371fec80c6ec2fa5a4ebd93966d4dff to your computer and use it in GitHub Desktop.
❌ A "simple" component which isn't really simple
function UserProfile({request}: {request: MyProfileRequest}) {
// can we have stale data while we're loading? I guess not?
if (request.isLoading) return <Spinner />
// this goes before checking the errors, so I presume we can't have
// data and an error together? Or maybe we just don't care if there's
// an error but we get data?
if (request.data) return <UserProfileCard user={request.data} />
// can we have an errorMessage without a statusCode?
// how would we render that?
if (request.errorMessage && request.statusCode) {
return <ErrorMessage
code={request.statusCode}
message={request.errorMessage} />
}
// will this ever be exercised? is this dead code?
return null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment