From d64b6f28542c905cd633e77e13e79443d54cedad Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 6 Jan 2023 01:15:47 +0100 Subject: [PATCH] TeactN: Fix detaching, remove unused code --- src/lib/teact/teactn.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/lib/teact/teactn.tsx b/src/lib/teact/teactn.tsx index 6ea582e38..6371a576b 100644 --- a/src/lib/teact/teactn.tsx +++ b/src/lib/teact/teactn.tsx @@ -54,7 +54,6 @@ const containers = new Map( container = { mapStateToProps, ownProps: props, - areMappedPropsChanged: false, forceUpdate, isDetached: false, detachReason: undefined, @@ -269,17 +266,15 @@ export function withGlobal( containers.set(id, container); } - if (container.areMappedPropsChanged) { - container.areMappedPropsChanged = false; - } - if (!container.mappedProps || !arePropsShallowEqual(container.ownProps, props)) { container.ownProps = props; - try { - container.mappedProps = mapStateToProps(currentGlobal, props, container.detachWhenChanged); - } catch (err: any) { - handleError(err); + if (!container.isDetached) { + try { + container.mappedProps = mapStateToProps(currentGlobal, props, container.detachWhenChanged); + } catch (err: any) { + handleError(err); + } } }