Closed m-bert closed 1 month ago
Could you check if this still works after the changes:
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
export default function EmptyExample() {
const [key, setKey] = React.useState(1);
const tap = Gesture.Tap()
.onStart(() => {
console.log('Tapped');
setKey((prev) => prev + 1);
})
.runOnJS(true);
return (
<View style={styles.container}>
<GestureDetector gesture={tap}>
<View
style={{ width: 100, height: 100, backgroundColor: 'green' }}
key={key}
/>
</GestureDetector>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
Could you check if this still works after the changes
Yes it does 😅
Description
findNodeHandle
is a utility function that allows us to get native view from React component. The problem is, that under the hood it usesfindDOMNode
, which is deprecated and will be removed in React 19. To get rid of this function, I've written our implementation that meets our requirements.Also, for new API we had to introduce a little trick (thanks @j-piasecki) - we add wrapper
div
withdisplay: contents;
style and we pass a ref to this element. With that change, it is much easier to get requiredHTMLElement
- we simply have to getdiv
fromref
and find first child (preferably the one withoutdisplay: contents;
)Test plan
Tested that example app works and no
findNodeHandle
error is thrown inStrictMode