Skip to content

Commit

Permalink
πŸ› Fixed infinite resfreshing on server for thumbnails
Browse files Browse the repository at this point in the history
We memoize the thumbnails for current page videos
  • Loading branch information
Mario-SO committed Aug 2, 2024
1 parent 15b4cb0 commit 6ae8e20
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/app/components/misc/VideoCard/VideoCardWithMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { IExtendedSession } from '@/lib/types'
import { formatDate } from '@/lib/utils/time'
import { EllipsisVertical } from 'lucide-react'
import Link from 'next/link'
import React, { ReactNode } from 'react'
import React, { ReactNode, useMemo } from 'react'
import { useEffect, useState } from 'react'

const VideoCardWithMenu = ({
Expand All @@ -34,6 +34,8 @@ const VideoCardWithMenu = ({
undefined
)

const memoizedSession = useMemo(() => session, [])

useEffect(() => {
const getThumbnail = async (session: IExtendedSession) => {
try {
Expand All @@ -48,7 +50,8 @@ const VideoCardWithMenu = ({
if (session) {
getThumbnail(session)
}
}, [session])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [memoizedSession])

return (
<div className="flex min-h-full w-full flex-col rounded-xl uppercase">
Expand Down

0 comments on commit 6ae8e20

Please sign in to comment.