From fb0e704e4aa5dd11da6e3fcbb6d1f6746bed945d Mon Sep 17 00:00:00 2001 From: Nikola Iliev Date: Tue, 19 Jan 2021 20:51:57 +0200 Subject: [PATCH] fix(react native): handle animated prop correctly on the animated callback * [RN] Handle changes of animate property * Delete trailing whitespaces --- src/native/Svg.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/native/Svg.tsx b/src/native/Svg.tsx index b60e77ea..db7932cc 100644 --- a/src/native/Svg.tsx +++ b/src/native/Svg.tsx @@ -44,8 +44,10 @@ class NativeSvg extends Component { duration: durMs, useNativeDriver: true, }).start(() => { - this.animatedValue.setValue(-1) - this.setAnimation() + if (this.props.animate) { + this.animatedValue.setValue(-1) + this.setAnimation() + } }) } @@ -55,6 +57,12 @@ class NativeSvg extends Component { } } + componentDidUpdate(prevProps: IContentLoaderProps) { + if (!prevProps.animate && this.props.animate) { + this.setAnimation() + } + } + render() { const { children,