Animated Sticker: Avoid initializing RLottie after unmount

This commit is contained in:
Alexander Zinchuk 2022-11-29 17:56:23 +01:00
parent 05f00511e5
commit a087e7a429

View File

@ -97,12 +97,23 @@ const AnimatedSticker: FC<OwnProps> = ({
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;