Last active
February 9, 2018 12:57
-
-
Save viniciusdacal/bef1bc3b6f5ee9ce15e017af0270f5d8 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
const UserList = ({ isLoading, results, error }) => { | |
const shouldDisplayLoader = !error && isLoading; | |
const shouldDisplayNoResults = !error && !isLoading && !results.length; | |
const shouldDisplayList = !error && !isLoading && results.length > 0; | |
return ( | |
<div> | |
<div> | |
<h1>Users</h1> | |
<a href="/users/create">New User</a> | |
</div> | |
<div> | |
{error && <span>Something is not right!</span>} | |
{shouldDisplayLoader && <span>Loading...</span>} | |
{shouldDisplayNoResults && ( | |
<span>No Results Found</span> | |
)} | |
{shouldDisplayList && ( | |
<ul> | |
{result.map((user) => ( | |
<li key={user.id}>{user.name}</li> | |
))} | |
</ul> | |
)} | |
</div> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment