Created
February 28, 2022 16:54
-
-
Save 28development/801ff19348db3480377f37b067e46c5f to your computer and use it in GitHub Desktop.
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
import useFetchAllSnippets from '@/hooks/useFetchAllSnippets' | |
import Snippet from '@/types/Snippet' | |
import SnippetItem from '@/components/snippet/SnippetItem' | |
import React from 'react' | |
const SnippetList = () => { | |
const { snippets, isError, isLoading } = useFetchAllSnippets() | |
if (isError) return <div>failed to load snippets</div> | |
if (isLoading) return <div>loading snippets...</div> | |
return ( | |
<div className="mt-4 md:w-10/12"> | |
<h1 className="sr-only">Recent snippets</h1> | |
<ul role="list" className="space-y-4"> | |
{snippets.data.map((snippet: Snippet) => ( | |
<React.Fragment key={snippet.id}> | |
<SnippetItem snippet={snippet} /> | |
</React.Fragment> | |
))} | |
</ul> | |
</div> | |
) | |
} | |
export default SnippetList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment