Teact: Check for mountState in cleanup (#5214)

This commit is contained in:
zubiden 2024-11-27 20:33:31 +04:00 committed by Alexander Zinchuk
parent 46c0dcb945
commit ecbc32d0fd

View File

@ -749,6 +749,10 @@ function scheduleEffect(
if (cleanup) {
const runEffectCleanup = () => safeExec(() => {
if (componentInstance.mountState === MountState.Unmounted) {
return;
}
// eslint-disable-next-line @typescript-eslint/naming-convention
let DEBUG_startAt: number | undefined;
if (DEBUG) {
@ -767,8 +771,6 @@ function scheduleEffect(
);
}
}
return undefined;
}, () => {
// eslint-disable-next-line no-console, max-len
console.error(`[Teact] Error in effect cleanup at cursor #${cursor} in ${componentInstance.name}`, componentInstance);