From eb5244c5a28ee3656da8516fde50d444eec46aa2 Mon Sep 17 00:00:00 2001 From: wooloo Date: Wed, 12 Mar 2025 23:09:02 +0800 Subject: [PATCH] fix: memo component not remounting on type switch --- src/reconcile.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/reconcile.ts b/src/reconcile.ts index c73aa16..533b267 100644 --- a/src/reconcile.ts +++ b/src/reconcile.ts @@ -1,4 +1,13 @@ -import { Fiber, FC, HookEffect, FreText, TAG, Action, FiberHost, FiberFinish } from './type' +import { + Fiber, + FC, + HookEffect, + FreText, + TAG, + Action, + FiberHost, + FiberFinish, +} from './type' import { createElement } from './dom' import { resetCursor } from './hook' import { schedule, shouldYield } from './schedule' @@ -30,7 +39,11 @@ const reconcile = (fiber?: Fiber) => { } const memo = (fiber: Fiber) => { - if ((fiber.type as FC).memo && fiber.old?.props) { + if ( + (fiber.type as FC).memo && + fiber.type === fiber.old?.type && + fiber.old?.props + ) { let scu = (fiber.type as FC).shouldUpdate || shouldUpdate if (!scu(fiber.props, fiber.old.props)) { // fast-fix