@@ -326,9 +326,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
326326 const isMessageTypeDeleted = message . type === 'deleted' ;
327327 const { client } = chatContext ;
328328
329- const [ rect , setRect ] = useState < { w : number ; h : number ; x : number ; y : number } | undefined > (
330- undefined ,
331- ) ;
329+ const rectRef = useRef < Rect > ( undefined ) ;
332330 const bubbleRect = useRef < Rect > ( undefined ) ;
333331 const contextMenuAnchorRef = useRef < View > ( null ) ;
334332
@@ -338,8 +336,8 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
338336 const layout = await measureInWindow ( messageWrapperRef , insets ) ;
339337 const bubbleLayout = await measureInWindow ( contextMenuAnchorRef , insets ) . catch ( ( ) => layout ) ;
340338
339+ rectRef . current = layout ;
341340 bubbleRect . current = bubbleLayout ;
342- setRect ( layout ) ;
343341 setOverlayMessageH ( layout ) ;
344342 openOverlay ( { id : messageOverlayId , messageId : message . id } ) ;
345343 } catch ( e ) {
@@ -814,6 +812,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
814812 const styles = useStyles ( {
815813 highlightedMessage : ( isTargetedMessage || message . pinned ) && ! isMessageTypeDeleted ,
816814 } ) ;
815+ const rect = rectRef . current ;
817816 const overlayItemsAnchorRect = bubbleRect . current ?? rect ;
818817
819818 if ( ! ( isMessageTypeDeleted || messageContentOrder . length ) ) {
0 commit comments