Skip to content

Instantly share code, notes, and snippets.

@28development
Created February 28, 2022 16:54
Show Gist options
  • Save 28development/d936400d652a8d0fc2fc36bb092e7891 to your computer and use it in GitHub Desktop.
Save 28development/d936400d652a8d0fc2fc36bb092e7891 to your computer and use it in GitHub Desktop.
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