mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-21 04:48:48 +01:00
[Perf] Animated Sticker: Avoid redundant data change on first render (#1576)
This commit is contained in:
parent
261ea66d5e
commit
8086003321
@ -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,8 +195,12 @@ const AnimatedSticker: FC<OwnProps> = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (animation) {
|
||||
animation.changeData(animationData);
|
||||
playAnimation();
|
||||
if (isFirstRender.current) {
|
||||
isFirstRender.current = false;
|
||||
} else {
|
||||
animation.changeData(animationData);
|
||||
playAnimation();
|
||||
}
|
||||
}
|
||||
}, [playAnimation, animation, animationData]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user