Created
January 31, 2018 20:14
-
-
Save viniciusdacal/12e1ee64ff85803036162292d23eeade 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 UserListResults = ({ error, results, isLoading }) => { | |
if (error) { | |
return <span>Something is not right!</span>; | |
} | |
if (isLoading) { | |
return <span>Loading...</span>; | |
} | |
if (!results.length) { | |
return <span>No Results Found</span>; | |
} | |
return ( | |
<ul> | |
{result.map((user) => ( | |
<li key={user.id}>{user.name}</li> | |
))} | |
</ul> | |
); | |
} | |
const UserList = ({ isLoading, results, error }) => ( | |
<div> | |
<h1>Users</h1> | |
<a href="/users/create">New User</a> | |
</div> | |
<div> | |
<UserListResults | |
error={error} | |
results={results} | |
isLoading={isLoading} | |
/> | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment