question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

This synthetic event is reused for performance reasons

See original GitHub issue

ERROR Warning: This synthetic event is reused for performance reasons. If you’re seeing this, you’re accessing the property nativeEvent on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist(). See https://reactjs.org/link/event-pooling for more information. WARN Possible Unhandled Promise Rejection (id: 0): TypeError: null is not an object (evaluating ‘_ref2.nativeEvent.layout’)

Reproduce

<Modalize
       modalHeight={600}
       alwaysOpen={130}
       withHandle
       modalStyle={homeModalizeStyles.modalStyle}
       HeaderComponent={position === 'initial' ? <HomeFooter /> : <HomeHeader />}
       FooterComponent={position === 'top' && <HomeFooter />}
       handleStyle={homeModalizeStyles.handleStyle}
       childrenStyle={homeModalizeStyles.childrenStyle}
       onPositionChange={setPosition}
       panGestureComponentEnabled
       flatListProps={{
         data: menu,
         keyExtractor: (item) => item.key,
         showsVerticalScrollIndicator: false,
         numColumns: 3,
         renderItem: ({item}) => {
           return (
             <View style={homeModalizeStyles.alignCenter}>
               <TouchableWithoutFeedback onPress={item.onPress}>
                 <View style={homeModalizeStyles.iconRounded}>
                   {item.isIcon ? (
                     <Icon name={item.icon} size={16} color={colors.black} />
                   ) : (
                     <MaterialCommunityIcons name={item.icon} color={colors.black} size={18} />
                   )}
                 </View>
               </TouchableWithoutFeedback>
               <View style={homeModalizeStyles.labelContainer}>
                 <Text style={homeModalizeStyles.label}>{item.title}</Text>
                 <Text style={homeModalizeStyles.label}>{item.subTitle}</Text>
               </View>
             </View>
           )
         },
       }}
     />

Dependencies:

  • react-native-modalize 2.1.1
  • react-native 0.70.1
  • react-native-gesture-handler ^2.6.1
  • react-native-navigation: not using

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:20

github_iconTop GitHub Comments

4reactions
Tanujgargcommented, Sep 21, 2022

I’m having the same problem after updating to 0.70.1.

3reactions
huszycommented, Nov 20, 2022

Hi, We are using the following patch in our project while it’s getting fixed. It persists the original event before the LayoutAnimation occurs. It’s far from perfect but works for us.

diff --git a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
index 6a343d8..474b2ec 100644
--- a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
+++ b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
@@ -111,6 +111,10 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
       this._initialFrameHeight = this._frame.height;
     }
 
+    if (this.props.onLayout) {
+      event.persist();
+    }
+
     if (wasFrameNull) {
       await this._updateBottomIfNecessary();
     }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: This synthetic event is reused for performance ...
This is what React documentation says about it: "The SyntheticEvent is pooled. This means that the SyntheticEvent object will be reused and all ......
Read more >
How to solve React's "This synthetic event is reused ... - akoskm
Warning: This synthetic event is reused for performance reasons. If you see this, you're accessing the property target on a ...
Read more >
event.persist() should be called when using React synthetic ...
React uses the SyntheticEvent objects to wrap native events. For performance reasons, synthetic events are pooled and reused across multiple ...
Read more >
React SyntheticEvent reuse - Medium
For performance reasons, React reuses the SyntheticEvent objects by pooling them. This means that the SyntheticEvent object is reused, ...
Read more >
This synthetic event is reused for performance reasons React ...
Coding example for the question Warning: This synthetic event is reused for performance reasons React-Reactjs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found