Last active
October 24, 2020 20:34
-
-
Save jhannes/486c893e85a8f29a6a94e1f31ae11f77 to your computer and use it in GitHub Desktop.
React Zombie spinner killer
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
function TodoList({ list }: { list: string }) { | |
const { data, error, loading, reload } = useLoader( | |
async () => listTodos(list), | |
[list] | |
); | |
return ( | |
<> | |
<h2>Items in {list}</h2> | |
{loading && <Spinner />} | |
{error && <ErrorView error={error} reload={reload} />} | |
{data && ( | |
<ul> | |
{data.map(item => ( | |
<li>{item}</li> | |
))} | |
</ul> | |
)} | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment