Skip to content

Commit

Permalink
fix(react native): handle animated prop correctly on the animated cal…
Browse files Browse the repository at this point in the history
…lback

* [RN] Handle changes of animate property
* Delete trailing whitespaces
  • Loading branch information
NikolaIliev authored Jan 19, 2021
1 parent c6da59d commit fb0e704
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/native/Svg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ class NativeSvg extends Component<IContentLoaderProps> {
duration: durMs,
useNativeDriver: true,
}).start(() => {
this.animatedValue.setValue(-1)
this.setAnimation()
if (this.props.animate) {
this.animatedValue.setValue(-1)
this.setAnimation()
}
})
}

Expand All @@ -55,6 +57,12 @@ class NativeSvg extends Component<IContentLoaderProps> {
}
}

componentDidUpdate(prevProps: IContentLoaderProps) {
if (!prevProps.animate && this.props.animate) {
this.setAnimation()
}
}

render() {
const {
children,
Expand Down

0 comments on commit fb0e704

Please sign in to comment.