chore: fix react render error

This commit is contained in:
daniyal 2024-09-11 16:47:55 +05:00
parent 990460d7cf
commit d15c5a21d9

View File

@ -13,7 +13,7 @@ import {
Filter as NostrEventFilter, Filter as NostrEventFilter,
UnsignedEvent UnsignedEvent
} from 'nostr-tools' } from 'nostr-tools'
import React, { useMemo } from 'react' import React, { useEffect, useMemo } from 'react'
import { Dispatch, SetStateAction, useState } from 'react' import { Dispatch, SetStateAction, useState } from 'react'
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
@ -58,6 +58,10 @@ export const Comments = ({ modDetails, setCommentCount }: Props) => {
author: AuthorFilterEnum.All_Comments author: AuthorFilterEnum.All_Comments
}) })
useEffect(() => {
setCommentCount(commentEvents.length)
}, [commentEvents, setCommentCount])
const userState = useAppSelector((state) => state.user) const userState = useAppSelector((state) => state.user)
useDidMount(async () => { useDidMount(async () => {
@ -202,8 +206,6 @@ export const Comments = ({ modDetails, setCommentCount }: Props) => {
return true return true
} }
setCommentCount(commentEvents.length)
const comments = useMemo(() => { const comments = useMemo(() => {
let filteredComments = commentEvents let filteredComments = commentEvents
if (filterOptions.author === AuthorFilterEnum.Creator_Comments) { if (filterOptions.author === AuthorFilterEnum.Creator_Comments) {