Skip to content

Commit 4aaf700

Browse files
committed
memoisation
1 parent 0304177 commit 4aaf700

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-native-gesture-handler/src/v3/HostGestureDetector.web.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
3333

3434
const viewRef = useRef(null);
3535
const propsRef = useRef<GestureHandlerDetectorProps>(props);
36+
const oldHandlerTags = useRef<Set<number>>(new Set<number>());
3637

3738
useEffect(() => {
3839
attachHandlers();
@@ -47,7 +48,11 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
4748
]);
4849

4950
const attachHandlers = (): void => {
50-
handlerTags.forEach((tag) => {
51+
const curHandlerTags = new Set(handlerTags);
52+
const newHandlerTags: Set<number> = curHandlerTags.difference(
53+
oldHandlerTags.current
54+
);
55+
newHandlerTags.forEach((tag) => {
5156
RNGestureHandlerModuleWeb.attachGestureHandler(
5257
tag,
5358
viewRef.current,

0 commit comments

Comments
 (0)