diff --git a/src/index.js b/src/index.js index da0e363..8372427 100644 --- a/src/index.js +++ b/src/index.js @@ -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); @@ -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, @@ -49,8 +49,6 @@ class Animation extends PureComponent { } }; - setAnimationDOMNode = (ref) => (this.animationDOMNode = ReactDOM.findDOMNode(ref)); - play = (...frames) => { if (!this.anim) { return; @@ -68,7 +66,7 @@ class Animation extends PureComponent { }; render() { - return ; + return ; } }