Skip to content

Commit 8d3e375

Browse files
authored
Merge pull request #383 from wooloo26/master
fix: memo component not remounting on type switch
2 parents a2235c9 + 95fc7fc commit 8d3e375

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/reconcile.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Fiber, FC, HookEffect, FreText, TAG, Action, FiberHost, FiberFinish } from './type'
1+
import {
2+
Fiber,
3+
FC,
4+
HookEffect,
5+
FreText,
6+
TAG,
7+
Action,
8+
FiberHost,
9+
FiberFinish,
10+
} from './type'
211
import { createElement } from './dom'
312
import { resetCursor } from './hook'
413
import { schedule, shouldYield } from './schedule'
@@ -30,7 +39,11 @@ const reconcile = (fiber?: Fiber) => {
3039
}
3140

3241
const memo = (fiber: Fiber) => {
33-
if ((fiber.type as FC).memo && fiber.old?.props) {
42+
if (
43+
(fiber.type as FC).memo &&
44+
fiber.type === fiber.old?.type &&
45+
fiber.old?.props
46+
) {
3447
let scu = (fiber.type as FC).shouldUpdate || shouldUpdate
3548
if (!scu(fiber.props, fiber.old.props)) {
3649
// fast-fix

0 commit comments

Comments
 (0)