reset animation state in TouchableOpacity and TouchableBounce (#44182)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44182

## Changelog:

[iOS] [Fixed] - Fixed stale state on TouchableOpacity and TouchableBounce

When TouchableOpacity and TouchableBounce are unmounted, we need to reset their state. This includes animation state. If we don't do that, view is unmounted on the mounting layer and animation will not be applied. This leaves view in undefined state. In TouchableOpacity, it is view with reduced opacity. TouchableBounce that is view with applied transform.

This was reported in https://github.com/facebook/react-native/issues/44044

Reviewed By: rubennorte, cipolleschi

Differential Revision: D56416571

fbshipit-source-id: 01214ec8a5e07c80a609e082b955a30305ad8396
This commit is contained in:
Samuel Susla
2024-05-01 18:09:08 +01:00
committed by Riccardo Cipolleschi
parent 0a4d97362f
commit 165cabb21f
2 changed files with 2 additions and 0 deletions
@@ -209,6 +209,7 @@ class TouchableBounce extends React.Component<Props, State> {
componentWillUnmount(): void {
this.state.pressability.reset();
this.state.scale.resetAnimation();
}
}
@@ -320,6 +320,7 @@ class TouchableOpacity extends React.Component<Props, State> {
componentWillUnmount(): void {
this.state.pressability.reset();
this.state.anim.resetAnimation();
}
}