remove unnecessary useRef (#46351)

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

changelog: [internal]

useRef here is not needed, let's remove it.

Reviewed By: yungsters

Differential Revision: D62235850

fbshipit-source-id: 77d50152f5423e8806cc28c18bcaf4803076e813
This commit is contained in:
Samuel Susla authored and Facebook GitHub Bot committed 2024-09-06 04:30:17 -07:00
1 parent 5fe7660439
commit 4c55e94dc5
1 file changed
+3 -7
@@ -247,16 +247,15 @@ function addAnimatedValuesListenersToProps(
function useAnimatedPropsLifecycle_layoutEffects(node: AnimatedProps): void {
const prevNodeRef = useRef<?AnimatedProps>(null);
const isUnmountingRef = useRef<boolean>(false);
const userDrivenAnimationEndedListener = useRef<?EventSubscription>(null);
useEffect(() => {
// It is ok for multiple components to call `flushQueue` because it noops
// if the queue is empty. When multiple animated components are mounted at
// the same time. Only first component flushes the queue and the others will noop.
NativeAnimatedHelper.API.flushQueue();
let drivenAnimationEndedListener: ?EventSubscription = null;
if (node.__isNative) {
userDrivenAnimationEndedListener.current =
drivenAnimationEndedListener =
NativeAnimatedHelper.nativeEventEmitter.addListener(
'onUserDrivenAnimationEnded',
data => {
@@ -266,10 +265,7 @@ function useAnimatedPropsLifecycle_layoutEffects(node: AnimatedProps): void {
}
return () => {
if (userDrivenAnimationEndedListener.current) {
userDrivenAnimationEndedListener.current?.remove();
userDrivenAnimationEndedListener.current = null;
}
drivenAnimationEndedListener?.remove();
};
});