Skip to content

Instantly share code, notes, and snippets.

@35d
Created October 17, 2018 06:59
Show Gist options
  • Save 35d/dc76d8d469921742c8e6a4526c37294f to your computer and use it in GitHub Desktop.
Save 35d/dc76d8d469921742c8e6a4526c37294f to your computer and use it in GitHub Desktop.
Lottie Animation Sample
// @flow
import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import LottieView from 'lottie-react-native';
import loading from '../assets/lottie/loading.json';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#333333',
},
});
export default class LottieAnimation extends Component {
loadingAnimation: LottieView;
componentDidMount() {
if (this.loadingAnimation) this.loadingAnimation.play();
}
render() {
return (
<View style={styles.container}>
<LottieView
style={{
width: 100,
height: 120,
paddingTop: 90,
alignSelf: 'center',
}}
ref={(refs) => {
this.loadingAnimation = refs;
}}
source={loading}
/>
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment