Skip to content

Instantly share code, notes, and snippets.

@28development
Created February 28, 2022 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 28development/801ff19348db3480377f37b067e46c5f to your computer and use it in GitHub Desktop.
Save 28development/801ff19348db3480377f37b067e46c5f 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