Skip to content

Instantly share code, notes, and snippets.

@jhannes
Last active October 24, 2020 20:34
Show Gist options
  • Save jhannes/486c893e85a8f29a6a94e1f31ae11f77 to your computer and use it in GitHub Desktop.
Save jhannes/486c893e85a8f29a6a94e1f31ae11f77 to your computer and use it in GitHub Desktop.
React Zombie spinner killer
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