Skip to content

Commit

Permalink
basic comment rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
malerba118 committed Feb 14, 2022
1 parent 58e9b42 commit 041c0bd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions components/Comments.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { Box } from "@chakra-ui/react";
import { Box, Spinner, Stack, Center } from "@chakra-ui/react";
import useComments from "../hooks/useComments";

interface CommentsProps {
Expand All @@ -9,7 +9,22 @@ interface CommentsProps {
const Comments: React.FunctionComponent<CommentsProps> = ({ topic }) => {
const query = useComments({ topic });

return <Box as="pre">{JSON.stringify(query.data, null, 2)}</Box>;
return (
<Box>
{query.isLoading && (
<Center p={8}>
<Spinner />
</Center>
)}
<Stack spacing={4}>
{query.data?.map((comment) => (
<Box key={comment.id} bg="whiteAlpha.100" rounded="lg" p={3}>
{comment.message}
</Box>
))}
</Stack>
</Box>
);
};

export default Comments;

0 comments on commit 041c0bd

Please sign in to comment.