-
-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CHORE] use UNSAFE_ #120
Open
jarretmoses
wants to merge
1
commit into
chenqingspring:master
Choose a base branch
from
Doorkee:minor-remove-react17.x-warning
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[CHORE] use UNSAFE_ #120
jarretmoses
wants to merge
1
commit into
chenqingspring:master
from
Doorkee:minor-remove-react17.x-warning
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR updates fix it: #109 |
Great change 👍 Any plan to merge it soon? |
Why this is not merged? |
|
Bumping |
This repo seems to no longer be maintained. Id suggest moving to https://github.com/airbnb/lottie-web as I did. I can give an example of how I used it here import {
useRef,
useEffect,
forwardRef,
useImperativeHandle,
} from 'react';
import lottie, { AnimationConfigWithPath, AnimationItem } from 'lottie-web';
const Lottie = ({
path,
className = '',
animationClassName = '',
loop = false,
renderer = 'svg',
onComplete,
speed,
viewBoxOnly,
testId = 'dk-lottie',
}: Props, ref: Ref) => {
const containerRef = useRef(null);
const animationRef = useRef<AnimationItem | null>(null);
useEffect(() => {
const rendererSettings = { viewBoxOnly, className: animationClassName.trim() };
const loadAnimationConfig = {
container: containerRef.current!,
renderer,
path,
loop,
autoplay: false,
rendererSettings,
};
const animationCallback = () => {
if (onComplete) {
onComplete();
}
};
animationRef.current = lottie.loadAnimation(loadAnimationConfig);
/*
If you want to be able to stop/play the instance through the animation ref, autoplay has to be set to false
the animationRef.current.play() below is starting the animation on componentDidMount
the equivalent of setting autoplay = true
*/
animationRef.current!.play();
if (speed) {
animationRef.current!.setSpeed(speed);
}
animationRef.current!.addEventListener('complete', animationCallback);
return () => {
animationRef.current!.removeEventListener('complete', animationCallback);
animationRef.current!.destroy();
};
});
useImperativeHandle(ref, () => ({
play: (name?: string) => {
animationRef.current!.play(name);
},
stop: (name?: string) => {
animationRef.current!.stop(name);
},
}));
return (
<div
ref={containerRef}
className={`dk-lottie ${className.trim()}`.trim()}
data-testid={testId}
/>
);
};
export const DKLottie = forwardRef(Lottie); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove warning pertaining to React 17.x