From 3e94958ab0910192385a90f18f2f1bc837c43c62 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 22 Mar 2022 11:21:36 -0300 Subject: [PATCH] Patch react-native-animated-numbers to not re-render indefinitely (#6080) --- .../react-native-animated-numbers+0.4.1.patch | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 patches/react-native-animated-numbers+0.4.1.patch diff --git a/patches/react-native-animated-numbers+0.4.1.patch b/patches/react-native-animated-numbers+0.4.1.patch new file mode 100644 index 000000000..a6027c2a5 --- /dev/null +++ b/patches/react-native-animated-numbers+0.4.1.patch @@ -0,0 +1,39 @@ +diff --git a/node_modules/react-native-animated-numbers/index.js b/node_modules/react-native-animated-numbers/index.js +index f624b91..af39f58 100644 +--- a/node_modules/react-native-animated-numbers/index.js ++++ b/node_modules/react-native-animated-numbers/index.js +@@ -1,4 +1,4 @@ +-import React from 'react'; ++import React, { useCallback } from 'react'; + import { Text, View } from 'react-native'; + import Animated, { EasingNode } from 'react-native-reanimated'; + +@@ -71,9 +71,9 @@ const AnimatedNumber = ({ + return new Animated.Value(animationHeight); + }); + +- const setButtonLayout = (e) => { ++ const setButtonLayout = useCallback((e) => { + setNumberHeight(e.nativeEvent.layout.height); +- }; ++ }, []); + + React.useEffect(() => { + animations.map((animation, index) => { +@@ -139,12 +139,14 @@ const AnimatedNumber = ({ + })} + + )} ++ {numberHeight === 0 && + +- {0} ++ {animateToNumberString} + ++ } + + ); + };