Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { PureComponent } from 'react';
import ReactDOM from 'react-dom';
import { View } from 'react-native';
import lottie from 'lottie-web';
import { createRef } from 'react';

class Animation extends PureComponent {
animationDOMNode = null;
theRef = createRef(null);

componentDidMount() {
this.loadAnimation(this.props);
Expand Down Expand Up @@ -36,7 +36,7 @@ class Animation extends PureComponent {
}

this.anim = lottie.loadAnimation({
container: this.animationDOMNode,
container: this.theRef.current,
animationData: props.source,
renderer: 'svg',
loop: props.loop || false,
Expand All @@ -49,8 +49,6 @@ class Animation extends PureComponent {
}
};

setAnimationDOMNode = (ref) => (this.animationDOMNode = ReactDOM.findDOMNode(ref));

play = (...frames) => {
if (!this.anim) {
return;
Expand All @@ -68,7 +66,7 @@ class Animation extends PureComponent {
};

render() {
return <View style={this.props.style} ref={this.setAnimationDOMNode} />;
return <View style={this.props.style} ref={this.theRef} />;
}
}

Expand Down