Skip to content

Commit fb0e704

Browse files
authored
fix(react native): handle animated prop correctly on the animated callback
* [RN] Handle changes of animate property * Delete trailing whitespaces
1 parent c6da59d commit fb0e704

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/native/Svg.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ class NativeSvg extends Component<IContentLoaderProps> {
4444
duration: durMs,
4545
useNativeDriver: true,
4646
}).start(() => {
47-
this.animatedValue.setValue(-1)
48-
this.setAnimation()
47+
if (this.props.animate) {
48+
this.animatedValue.setValue(-1)
49+
this.setAnimation()
50+
}
4951
})
5052
}
5153

@@ -55,6 +57,12 @@ class NativeSvg extends Component<IContentLoaderProps> {
5557
}
5658
}
5759

60+
componentDidUpdate(prevProps: IContentLoaderProps) {
61+
if (!prevProps.animate && this.props.animate) {
62+
this.setAnimation()
63+
}
64+
}
65+
5866
render() {
5967
const {
6068
children,

0 commit comments

Comments
 (0)