diff --git a/app/routes/_gcn.user.endorsements/route.tsx b/app/routes/_gcn.user.endorsements/route.tsx index 3f1623ead..0542e9300 100644 --- a/app/routes/_gcn.user.endorsements/route.tsx +++ b/app/routes/_gcn.user.endorsements/route.tsx @@ -26,7 +26,7 @@ import { useRef, useState, } from 'react' -import { useElementSize } from 'usehooks-ts' +import { useResizeObserver } from 'usehooks-ts' import { formatAuthor } from '../_gcn.circulars/circulars.lib' import type { @@ -232,8 +232,11 @@ export function EndorsementRequestCard({ const disabled = fetcher.state !== 'idle' const [showMore, setShowMore] = useState(false) - const [noteRef, { width }] = useElementSize() - const [noteContainerRef, { width: containerWidth }] = useElementSize() + const noteRef = useRef(null) + const noteContainerRef = useRef(null) + + const { width } = useResizeObserver({ ref: noteRef }) + const { width: containerWidth } = useResizeObserver({ ref: noteContainerRef }) return ( @@ -246,7 +249,10 @@ export function EndorsementRequestCard({ {endorsementRequest.note && (
Comments from the user: - {(width > containerWidth || showMore) && ( + {((width !== undefined && + containerWidth !== undefined && + width > containerWidth) || + showMore) && (