Created
July 18, 2022 23:19
-
-
Save rayrayzayzay/a8c6f18ab3786e2da5fb005ccfa1f197 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
❌ The complex component got even more complex | |
function UserProfile({request}: | |
{request: MyProfileRequest}) { | |
// 🤞 let's hope this boolean | |
combination is right | |
if (request.isLoading && !request.data && | |
!request.errorMessage) { | |
return <Spinner /> | |
} | |
if (request.data) { | |
return (<UserProfileCard | |
isLoading={request.isLoading} | |
user={request.data} | |
/>) | |
} | |
// still hope we get both of these here! | |
if (request.errorMessage && request.statusCode) { | |
return (<> | |
<ErrorMessage | |
code={request.statusCode} | |
message={request.errorMessage} | |
/> | |
{request.isLoading && <Spinner />} // | |
nested conditions are a bit unpleasant | |
</>) | |
} | |
// I hope we don't get here | |
return null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment