From a087e7a429d69e02c0ffb21dc0edd3503b5f7efd Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 29 Nov 2022 17:56:23 +0100 Subject: [PATCH] Animated Sticker: Avoid initializing RLottie after unmount --- src/components/common/AnimatedSticker.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/common/AnimatedSticker.tsx b/src/components/common/AnimatedSticker.tsx index 38ed54427..8146d2b90 100644 --- a/src/components/common/AnimatedSticker.tsx +++ b/src/components/common/AnimatedSticker.tsx @@ -97,12 +97,23 @@ const AnimatedSticker: FC = ({ const playSegmentRef = useRef<[number, number]>(); playSegmentRef.current = playSegment; + const isUnmountedRef = useRef(); + useEffect(() => { + return () => { + isUnmountedRef.current = true; + }; + }, []); + useEffect(() => { if (animation || !tgsUrl || (sharedCanvas && !sharedCanvasCoords)) { return; } const exec = () => { + if (isUnmountedRef.current) { + return; + } + const container = containerRef.current || sharedCanvas; if (!container) { return;