Skip to content

Update hook usage in the NativeDetector - #3714

Merged
j-piasecki merged 3 commits into
nextfrom
@jpiasecki/update-hooks
Sep 29, 2025
Merged

Update hook usage in the NativeDetector#3714
j-piasecki merged 3 commits into
nextfrom
@jpiasecki/update-hooks

Conversation

@j-piasecki

Copy link
Copy Markdown
Member

Description

  1. Merges two useEffects with the same dependency array into one in useGesture
  2. Adds useEffect responsible for updating the propsRef in HostGestureDetector.web.tsx
  3. Removes useEffects which were only calling detachHandlers and replaces them with a cleanup function in HostGestureDetector.web.tsx

@j-piasecki j-piasecki changed the title Update how hooks are used Update hook usage in the NativeDetector Sep 18, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes React hook usage in the gesture handler components by consolidating duplicate effects and improving lifecycle management.

  • Merges two useEffect hooks with identical dependency arrays in useGesture to eliminate redundancy
  • Adds proper propsRef updates through a dedicated useEffect in HostGestureDetector.web.tsx
  • Replaces standalone cleanup useEffect hooks with inline cleanup functions for better lifecycle management

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
useGesture.ts Consolidates two useEffect hooks with same dependencies into one
HostGestureDetector.web.tsx Adds propsRef update effect and replaces cleanup effects with cleanup function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts
@akwasniewski akwasniewski mentioned this pull request Sep 25, 2025

@akwasniewski akwasniewski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@j-piasecki
j-piasecki merged commit 4790449 into next Sep 29, 2025
2 checks passed
@j-piasecki
j-piasecki deleted the @jpiasecki/update-hooks branch September 29, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants