diff --git a/src/makeLottiePlayer.js b/src/makeLottiePlayer.js index 542fe37..ee35a19 100644 --- a/src/makeLottiePlayer.js +++ b/src/makeLottiePlayer.js @@ -5,34 +5,38 @@ import React, { import equal from 'fast-deep-equal/es6/react'; import clone from 'rfdc/default'; -import { propTypes, defaultProps } from './props'; +import propTypes from './propTypes'; + +const emptyObject = {}; +const noOp = () => {}; const makeLottiePlayer = ({ loadAnimation }) => { - const Lottie = memo(forwardRef(({ - animationData, - path, - - play, - speed, - direction, - segments: segmentsIn, - goTo, - useSubframes, - - renderer, - loop, - rendererSettings: rendererSettingsIn, - - audioFactory, - - onLoad, - onComplete, - onLoopComplete, - onEnterFrame, - onSegmentStart, - - ...props - }, forwardedRef) => { + const Lottie = memo(forwardRef((params, forwardedRef) => { + const { + animationData = null, + path = null, + + play = null, + speed = 1, + direction = 1, + segments: segmentsIn = null, + goTo = null, + useSubframes = true, + + renderer = 'svg', + loop = true, + rendererSettings: rendererSettingsIn = emptyObject, + + audioFactory = null, + + onLoad = noOp, + onComplete = noOp, + onLoopComplete = noOp, + onEnterFrame = noOp, + onSegmentStart = noOp, + ...props + } = params; + const animElementRef = useRef(); const animRef = useRef(); @@ -207,7 +211,6 @@ const makeLottiePlayer = ({ loadAnimation }) => { })); Lottie.propTypes = propTypes; - Lottie.defaultProps = defaultProps; return Lottie; }; diff --git a/src/props.js b/src/propTypes.js similarity index 64% rename from src/props.js rename to src/propTypes.js index f009552..48b4404 100644 --- a/src/props.js +++ b/src/propTypes.js @@ -1,7 +1,7 @@ // eslint-disable-next-line import/no-extraneous-dependencies import PropTypes from 'prop-types'; -export const propTypes = { +export default { // You can use either animationData OR path animationData: PropTypes.object, path: PropTypes.string, @@ -26,28 +26,3 @@ export const propTypes = { onEnterFrame: PropTypes.func, onSegmentStart: PropTypes.func, }; - -export const defaultProps = { - animationData: null, - path: null, - - play: null, - segments: null, - goTo: null, - useSubframes: true, - - speed: 1, - direction: 1, - loop: true, - - rendererSettings: {}, - renderer: 'svg', - - audioFactory: null, - - onLoad: () => {}, - onComplete: () => {}, - onLoopComplete: () => {}, - onEnterFrame: () => {}, - onSegmentStart: () => {}, -};