Skip to content

Memoize internal event handlers - #3812

Merged
j-piasecki merged 1 commit into
nextfrom
@jpiasecki/memoize-event-handlers
Nov 14, 2025
Merged

j-piasecki merged 1 commit into
nextfrom
@jpiasecki/memoize-event-handlers

Conversation

@j-piasecki

Copy link
Copy Markdown
Member

Description

  • Our non-reanimated "hooks" weren't memoized by the compiler since they weren't actually hooks. Due to this, their result was never referentially stable.
  • Since we're doing manual memoization inside useGesture, it also wasn't memoized automatically, and its result wasn't referentially stable.
  • Creation of gestures inside useMemo was failing with the compiler enabled, since it was inlining its content outside of memo.

Test plan

Check the basic example. Enable React compiler and see that the app no longer crashes on rerenders.

@j-piasecki
j-piasecki merged commit a2216e2 into next Nov 14, 2025
2 checks passed
@j-piasecki
j-piasecki deleted the @jpiasecki/memoize-event-handlers branch November 14, 2025 08:35
j-piasecki added a commit that referenced this pull request Nov 14, 2025
## Description

Currently config is cloned and modified on every render in gesture
hooks. This PR changes that, so that it's memoized assuming the input is
also stable.

## Test plan

Verify that if the input config is memoized, the returned gesture
reference is stable as long as the config doesn't change (will require
other PRs to be merged first).
-
#3815
-
#3812
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.

2 participants