From 23baa68a254682bd57f1f92b6f76cd08c328d8e1 Mon Sep 17 00:00:00 2001 From: Aaron William Po Date: Tue, 2 May 2023 19:50:36 -0400 Subject: [PATCH] Fix bug where comments would not update when edited --- src/components/BeerById/BeerPostCommentsSection.tsx | 1 + src/components/BreweryById/BreweryCommentsSection.tsx | 1 + src/components/ui/CommentsComponent.tsx | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/BeerById/BeerPostCommentsSection.tsx b/src/components/BeerById/BeerPostCommentsSection.tsx index 1d7a6b6..80186d5 100644 --- a/src/components/BeerById/BeerPostCommentsSection.tsx +++ b/src/components/BeerById/BeerPostCommentsSection.tsx @@ -62,6 +62,7 @@ const BeerPostCommentsSection: FC = ({ beerPost }) pageSize={PAGE_SIZE} setSize={setSize} size={size} + mutate={mutate} /> ) } diff --git a/src/components/BreweryById/BreweryCommentsSection.tsx b/src/components/BreweryById/BreweryCommentsSection.tsx index 15758fa..f4be52d 100644 --- a/src/components/BreweryById/BreweryCommentsSection.tsx +++ b/src/components/BreweryById/BreweryCommentsSection.tsx @@ -134,6 +134,7 @@ const BreweryCommentsSection: FC = ({ breweryPost }) => setSize={setSize} size={size} commentSectionRef={commentSectionRef} + mutate={mutate} /> ) } diff --git a/src/components/ui/CommentsComponent.tsx b/src/components/ui/CommentsComponent.tsx index 6796372..f91484c 100644 --- a/src/components/ui/CommentsComponent.tsx +++ b/src/components/ui/CommentsComponent.tsx @@ -1,6 +1,6 @@ import { FC, MutableRefObject } from 'react'; import { FaArrowUp } from 'react-icons/fa'; -import { mutate } from 'swr'; + import { useInView } from 'react-intersection-observer'; import useBeerPostComments from '@/hooks/useBeerPostComments'; @@ -25,6 +25,9 @@ interface CommentsComponentProps { isLoadingMore: ReturnType< typeof useBeerPostComments | typeof useBreweryPostComments >['isLoadingMore']; + mutate: ReturnType< + typeof useBeerPostComments | typeof useBreweryPostComments + >['mutate']; } const CommentsComponent: FC = ({ @@ -35,6 +38,7 @@ const CommentsComponent: FC = ({ pageSize, setSize, size, + mutate, }) => { const { ref: penultimateCommentRef } = useInView({ /**