Wrap useResizeObserver dependency in useCallback (#16972)

GitOrigin-RevId: fd4a10a2897878361a87bb02c5c6e8e6abfa8f26
This commit is contained in:
Alf Eaton 2024-02-09 09:17:47 +00:00 committed by Copybot
parent ea4d63876a
commit e9dbaf20b8

View file

@ -1,4 +1,4 @@
import { useState } from 'react'
import { useCallback, useState } from 'react'
import { useResizeObserver } from '../../../shared/hooks/use-resize-observer'
import { useTranslation } from 'react-i18next'
import classNames from 'classnames'
@ -13,9 +13,14 @@ export default function PdfLogEntryRawContent({
const [expanded, setExpanded] = useState(false)
const [needsExpander, setNeedsExpander] = useState(false)
const { elementRef } = useResizeObserver(element => {
setNeedsExpander(element.scrollHeight > collapsedSize)
})
const { elementRef } = useResizeObserver(
useCallback(
element => {
setNeedsExpander(element.scrollHeight > collapsedSize)
},
[collapsedSize]
)
)
const { t } = useTranslation()