From 27f0198e8c71fba981786a4332eec609b917514b Mon Sep 17 00:00:00 2001 From: Luis Miguel Alvarado Date: Wed, 23 Oct 2024 21:03:00 -0400 Subject: [PATCH] Add early return to useStyleTransition Return early if we don't have anything to animate. Close #226 --- .../src/native/modules/useStyleTransition.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/react-strict-dom/src/native/modules/useStyleTransition.js b/packages/react-strict-dom/src/native/modules/useStyleTransition.js index f796da5..d217757 100644 --- a/packages/react-strict-dom/src/native/modules/useStyleTransition.js +++ b/packages/react-strict-dom/src/native/modules/useStyleTransition.js @@ -275,6 +275,16 @@ export function useStyleTransition(style: ReactNativeStyle): ReactNativeStyle { } }, [animatedValue]); + if ( + _delay == null && + _duration == null && + _transitionProperty == null && + _timingFunction == null + ) { + // Avoid further calculations if we don't have anything to animate + return style; + } + if (transitionStyleHasChanged(transitionStyle, currentStyle)) { setCurrentStyle(style); setPreviousStyle(currentStyle);