From 75d72fe884c79c1a430c7f884c6333a7ed12e300 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sun, 9 May 2021 03:11:42 +0300 Subject: [PATCH] Teact: Fix for `useState` --- src/lib/teact/teact.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib/teact/teact.ts b/src/lib/teact/teact.ts index 8c2b71cc1..4f5c4c189 100644 --- a/src/lib/teact/teact.ts +++ b/src/lib/teact/teact.ts @@ -447,10 +447,6 @@ export function useState(initial?: T): [T, StateHookSetter] { value: initial, nextValue: initial, setter: ((componentInstance) => (newValue: ((current: T) => T) | T) => { - if (!componentInstance.isMounted) { - return; - } - if (byCursor[cursor].nextValue !== newValue) { byCursor[cursor].nextValue = typeof newValue === 'function' ? (newValue as (current: T) => T)(byCursor[cursor].value) @@ -466,8 +462,8 @@ export function useState(initial?: T): [T, StateHookSetter] { console.log( '[Teact.useState]', componentInstance.name, - // eslint-disable-next-line max-len - (componentInstance.Component as FC_withDebug).DEBUG_contentComponentName + // `componentInstance.Component` may be set to `null` by GC helper + componentInstance.Component && (componentInstance.Component as FC_withDebug).DEBUG_contentComponentName ? `> ${(componentInstance.Component as FC_withDebug).DEBUG_contentComponentName}` : '', `Forced update at cursor #${cursor}, next value: `,