Skip to content

Commit

Permalink
Merge pull request #105 from KDederichs/bugfix/100-remove-defaultProps
Browse files Browse the repository at this point in the history
Bugfix/100 remove default props
  • Loading branch information
mifi authored Aug 23, 2023
2 parents f8f8ae7 + 3bee1af commit cbc88b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 53 deletions.
57 changes: 30 additions & 27 deletions src/makeLottiePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -207,7 +211,6 @@ const makeLottiePlayer = ({ loadAnimation }) => {
}));

Lottie.propTypes = propTypes;
Lottie.defaultProps = defaultProps;

return Lottie;
};
Expand Down
27 changes: 1 addition & 26 deletions src/props.js → src/propTypes.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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: () => {},
};

0 comments on commit cbc88b4

Please sign in to comment.