Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created March 8, 2018 10:41
Show Gist options
  • Save amandeepmittal/8e64df91d9632143dd13d6d06825b71c to your computer and use it in GitHub Desktop.
Save amandeepmittal/8e64df91d9632143dd13d6d06825b71c to your computer and use it in GitHub Desktop.
componentWillMount() {
this._playAnimation();
}
_playAnimation = () => {
if (!this.state.animation) {
this._loadAnimationAsync();
} else {
this.animation.reset();
this.animation.play();
}
};
_loadAnimationAsync = async () => {
let result = await fetch(
'https://www.lottiefiles.com/storage/datafiles/a795e9d1bd5672fd901329d51661db5c/JSON/location.json'
);
this.setState(
{ animation: JSON.parse(result._bodyText) },
this._playAnimation
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment