|
1 | | -import React, { useState } from 'react'; |
| 1 | +import React, { useMemo, useState } from 'react'; |
2 | 2 | import { Dimensions, LayoutChangeEvent, StyleSheet, View } from 'react-native'; |
3 | 3 |
|
4 | 4 | import { Gesture, GestureDetector } from 'react-native-gesture-handler'; |
@@ -274,30 +274,38 @@ const MessageSimpleWithContext = < |
274 | 274 | ], |
275 | 275 | })); |
276 | 276 |
|
277 | | - const renderMessageBubble = ( |
278 | | - <View style={[styles.contentWrapper, contentWrapper]}> |
279 | | - <MessageContent |
280 | | - backgroundColor={backgroundColor} |
281 | | - noBorder={noBorder} |
282 | | - setMessageContentWidth={setMessageContentWidth} |
283 | | - /> |
284 | | - {reactionListPosition === 'top' && ReactionListTop ? ( |
285 | | - <ReactionListTop messageContentWidth={messageContentWidth} /> |
286 | | - ) : null} |
287 | | - </View> |
| 277 | + const renderMessageBubble = useMemo( |
| 278 | + () => ( |
| 279 | + <View style={[styles.contentWrapper, contentWrapper]}> |
| 280 | + <MessageContent |
| 281 | + backgroundColor={backgroundColor} |
| 282 | + noBorder={noBorder} |
| 283 | + setMessageContentWidth={setMessageContentWidth} |
| 284 | + /> |
| 285 | + {reactionListPosition === 'top' && ReactionListTop ? ( |
| 286 | + <ReactionListTop messageContentWidth={messageContentWidth} /> |
| 287 | + ) : null} |
| 288 | + </View> |
| 289 | + ), |
| 290 | + // eslint-disable-next-line react-hooks/exhaustive-deps |
| 291 | + [messageContentWidth, reactionListPosition], |
288 | 292 | ); |
289 | 293 |
|
290 | | - const renderAnimatedMessageBubble = ( |
291 | | - <GestureDetector gesture={swipeGesture}> |
292 | | - <View hitSlop={messageSwipeToReplyHitSlop} style={[styles.contentWrapper, contentWrapper]}> |
293 | | - <Animated.View |
294 | | - style={[styles.swipeContentContainer, swipeContentAnimatedStyle, swipeContentContainer]} |
295 | | - > |
296 | | - {MessageSwipeContent ? <MessageSwipeContent /> : null} |
297 | | - </Animated.View> |
298 | | - <Animated.View style={messageBubbleAnimatedStyle}>{renderMessageBubble}</Animated.View> |
299 | | - </View> |
300 | | - </GestureDetector> |
| 294 | + const renderAnimatedMessageBubble = useMemo( |
| 295 | + () => ( |
| 296 | + <GestureDetector gesture={swipeGesture}> |
| 297 | + <View hitSlop={messageSwipeToReplyHitSlop} style={[styles.contentWrapper, contentWrapper]}> |
| 298 | + <Animated.View |
| 299 | + style={[styles.swipeContentContainer, swipeContentAnimatedStyle, swipeContentContainer]} |
| 300 | + > |
| 301 | + {MessageSwipeContent ? <MessageSwipeContent /> : null} |
| 302 | + </Animated.View> |
| 303 | + <Animated.View style={messageBubbleAnimatedStyle}>{renderMessageBubble}</Animated.View> |
| 304 | + </View> |
| 305 | + </GestureDetector> |
| 306 | + ), |
| 307 | + // eslint-disable-next-line react-hooks/exhaustive-deps |
| 308 | + [reactionListPosition, messageContentWidth], |
301 | 309 | ); |
302 | 310 |
|
303 | 311 | return ( |
|
0 commit comments