Skip to content

[iOS] Handle view recycling in Touchable#4131

Merged
j-piasecki merged 2 commits into
mainfrom
@jpiasecki/ios-fix-touchable-default-props-recycling
Apr 30, 2026
Merged

[iOS] Handle view recycling in Touchable#4131
j-piasecki merged 2 commits into
mainfrom
@jpiasecki/ios-fix-touchable-default-props-recycling

Conversation

@j-piasecki
Copy link
Copy Markdown
Member

Description

Due to the Fabric view recycling not being handled correctly by the native button implementations, the default* props were not applied correctly when the button instances were being reused. This presented itself by buttons being styled correctly on the first mount, but not during the following ones.

This PR addresses that.

Test plan

Before After
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-04-29.at.12.02.29.mov
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-04-29.at.12.01.17.mov

Copilot AI review requested due to automatic review settings April 29, 2026 10:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect visual defaults when Touchable/native button views are reused under Fabric view recycling, ensuring recycled instances return to a clean animation/press state and re-apply default visual props correctly.

Changes:

  • Add explicit recycle-time reset hooks for the Fabric button component view and the underlying native button.
  • Force a one-shot re-application of the idle (“start animation”) state after recycling to ensure default* props are applied.
  • Preserve wrapper-layer opacity across finalizeUpdates to avoid React re-renders clobbering press/idle visuals.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm Adds prepareForRecycle, tracks recycle state to re-apply idle visuals, and snapshots/restores wrapper-layer opacity in finalizeUpdates.
packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm Adds prepareForRecycle to cancel pending animations/blocks and reset transient press visual state (transform/alpha/underlay).
packages/react-native-gesture-handler/apple/RNGestureHandlerButton.h Exposes prepareForRecycle API with documentation for Fabric recycling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j-piasecki j-piasecki requested a review from m-bert April 29, 2026 10:41
Copy link
Copy Markdown
Collaborator

@m-bert m-bert left a comment

Choose a reason for hiding this comment

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

Looks good

@j-piasecki j-piasecki merged commit 5460083 into main Apr 30, 2026
3 checks passed
@j-piasecki j-piasecki deleted the @jpiasecki/ios-fix-touchable-default-props-recycling branch April 30, 2026 05:24
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.

3 participants