Last active
January 9, 2019 03:06
-
-
Save viniciusdacal/89a2dba1920ad851d4e88a89ea429729 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 }) => ( | |
<div> | |
<div> | |
<h1>Users</h1> | |
<a href="/users/create">New User</a> | |
</div> | |
<div> | |
{error && <span>Something is not right!</span>} | |
{!error && isLoading && <span>Loading...</span>} | |
{!error && !isLoading && !results.length && ( | |
<span>No Results Found</span> | |
)} | |
{!error && !isLoading && results.length > 0 && ( | |
<ul> | |
{result.map((user) => ( | |
<li key={user.id}>{user.name}</li> | |
))} | |
</ul> | |
)} | |
{!error && !isLoading && results.length > 0 && ( | |
<ul> | |
{result.map((user) => ( | |
<li key={user.id}>{user.name}</li> | |
))} | |
</ul> | |
)} | |
</div> | |
</div> | |
); |
Loop with results listed twice:
{!error` && !isLoading && results.length > 0 && (
<ul>
{result.map((user) => (
<li key={user.id}>{user.name}</li>
))}
</ul>
)}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As linhas 14 a 20 são iguais as 21 a 27, não?