From c8de85302199da340a60b1003a479a0ea6da1d87 Mon Sep 17 00:00:00 2001 From: * <8> Date: Wed, 19 Jan 2022 18:09:09 +0800 Subject: [PATCH] Match-id-4496de588b05125fe488277a86323c173cecf054 --- libs/horizon/src/renderer/UpdateHandler.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/libs/horizon/src/renderer/UpdateHandler.ts b/libs/horizon/src/renderer/UpdateHandler.ts index 681dab4d..473d8fe4 100644 --- a/libs/horizon/src/renderer/UpdateHandler.ts +++ b/libs/horizon/src/renderer/UpdateHandler.ts @@ -42,18 +42,6 @@ export function pushUpdate(vNode: VNode, update: Update) { updates.push(update); } -function getCallback( - update: Update, - inst: any, - oldState: any, - props: any,): any { - const content = update.content; - const newState = typeof content === 'function' ? content.call(inst, oldState, props) : content; - return (newState === null || newState === undefined) - ? oldState - : { ...oldState, ...newState }; -} - // 根据update获取新的state function calcState( vNode: VNode, @@ -72,9 +60,12 @@ function calcState( case UpdateState.Error: FlagUtils.removeFlag(vNode, ShouldCapture); FlagUtils.markDidCapture(vNode); - return getCallback(update, inst, oldState, props); case UpdateState.Update: - return getCallback(update, inst, oldState, props); + const updateContent = update.content; + const newState = typeof updateContent === 'function' ? updateContent.call(inst, oldState, props) : updateContent; + return (newState === null || newState === undefined) + ? oldState + : { ...oldState, ...newState }; default: return oldState; }