From c6c4ec9caa19df5ce841cb81f98defa12ad9a291 Mon Sep 17 00:00:00 2001 From: * <8> Date: Mon, 21 Feb 2022 17:43:04 +0800 Subject: [PATCH] Match-id-a915f78dcc8ebc19fdc1e4577d27d7bd4cd75d4a --- .../renderer/render/class/ClassLifeCycleProcessor.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/horizon/src/renderer/render/class/ClassLifeCycleProcessor.ts b/libs/horizon/src/renderer/render/class/ClassLifeCycleProcessor.ts index 90f662c3..153094e0 100644 --- a/libs/horizon/src/renderer/render/class/ClassLifeCycleProcessor.ts +++ b/libs/horizon/src/renderer/render/class/ClassLifeCycleProcessor.ts @@ -118,15 +118,19 @@ export function callComponentWillUpdate(inst, newProps, newState, nextContext) { } export function callComponentWillReceiveProps(inst, newProps: object, newContext: object) { - const oldState = inst.state; if (inst.componentWillReceiveProps) { + const oldState = inst.state; inst.componentWillReceiveProps(newProps, newContext); + if (inst.state !== oldState) { + changeStateContent.call(inst, UpdateState.Override, inst.state, null); + } } if (inst.UNSAFE_componentWillReceiveProps) { + const oldState = inst.state; inst.UNSAFE_componentWillReceiveProps(newProps, newContext); - } - if (inst.state !== oldState) { - changeStateContent.call(inst, UpdateState.Override, inst.state, null); + if (inst.state !== oldState) { + changeStateContent.call(inst, UpdateState.Override, inst.state, null); + } } }