[Perf] Animated Sticker: Avoid redundant data change on first render (#1576)

This commit is contained in:
Alexander Zinchuk 2021-12-10 18:33:47 +01:00
parent 261ea66d5e
commit 8086003321

View File

@ -60,6 +60,7 @@ const AnimatedSticker: FC<OwnProps> = ({
const container = useRef<HTMLDivElement>(null);
const wasPlaying = useRef(false);
const isFrozen = useRef(false);
const isFirstRender = useRef(true);
const playRef = useRef();
playRef.current = play;
@ -194,9 +195,13 @@ const AnimatedSticker: FC<OwnProps> = ({
useEffect(() => {
if (animation) {
if (isFirstRender.current) {
isFirstRender.current = false;
} else {
animation.changeData(animationData);
playAnimation();
}
}
}, [playAnimation, animation, animationData]);
useHeavyAnimationCheck(freezeAnimation, unfreezeAnimation);