Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Fabric event receivers init only once (#6907)
## Summary Fixes #6896 When adding support for fabric, we have inadvertently kept previous listeners still active for fabric. This way, we registered twice with the same `NodesManager` for React Native's `FabricEventDispatcher`, resulting in pretty much all the events doubling in number on android. I added a simple check that takes care of it. ## Test plan Paste the following into `EmptyExample` and run `FabricExample`. Check logs making sure that both `start` and `end` are logged only once per gesture. ```TSX import React, { useState } from 'react'; import { View, Text } from 'react-native'; import Animated, { useAnimatedScrollHandler } from 'react-native-reanimated'; function EmptyExample() { const [w, sW] = useState(0); const scrollHandler = useAnimatedScrollHandler({ onBeginDrag() { console.log('start'); }, onMomentumEnd() { console.log('end'); }, }); return ( <View style={{ flex: 1 }} onLayout={(evt) => sW(evt.nativeEvent.layout.width)}> <Animated.ScrollView onScroll={scrollHandler} horizontal snapToInterval={w} decelerationRate="fast"> {Array.from({ length: 20 }) .fill(0) .map((_, i) => { return ( <View key={i} style={{ width: w }}> <Text>{i}</Text> </View> ); })} </Animated.ScrollView> </View> ); } export default EmptyExample; ```
- Loading branch information