Created
July 18, 2022 23:15
-
-
Save rayrayzayzay/8371fec80c6ec2fa5a4ebd93966d4dff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❌ 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