From 0b11905b3561b3d6b293bedbe3b433a9949888c1 Mon Sep 17 00:00:00 2001 From: * <8> Date: Wed, 14 Sep 2022 14:51:37 +0800 Subject: [PATCH] Match-id-a259fe636f4eae5da9d6448d48172e8ce9dcfcee --- .../src/renderer/vnode/VNodeCreator.ts | 2 +- scripts/__tests__/ComponentTest/Memo.test.js | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 scripts/__tests__/ComponentTest/Memo.test.js diff --git a/libs/horizon/src/renderer/vnode/VNodeCreator.ts b/libs/horizon/src/renderer/vnode/VNodeCreator.ts index 79496323..6416a7b7 100644 --- a/libs/horizon/src/renderer/vnode/VNodeCreator.ts +++ b/libs/horizon/src/renderer/vnode/VNodeCreator.ts @@ -230,7 +230,7 @@ export function onlyUpdateChildVNodes(processing: VNode): VNode | null { } }; - putChildrenIntoQueue(processing.child); + putChildrenIntoQueue(processing); while (queue.length) { const vNode = queue.shift()!; diff --git a/scripts/__tests__/ComponentTest/Memo.test.js b/scripts/__tests__/ComponentTest/Memo.test.js new file mode 100644 index 00000000..b1a6fa9f --- /dev/null +++ b/scripts/__tests__/ComponentTest/Memo.test.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. + */ + +import * as Horizon from '@cloudsop/horizon/index.ts'; + +describe('Memo Test', () => { + it('Memo should not make the path wrong', function () { + let updateApp; + + function Child() { + const [_, update] = Horizon.useState({}); + updateApp = () => update({}); + return
; + } + const MemoChild = Horizon.memo(Child); + + function App() { + return ( +
+ +
+ ); + } + const MemoApp = Horizon.memo(App); + Horizon.render( +
+ +
, + container + ); + Horizon.render( +
+ + +
, + container + ); + expect(() => updateApp()).not.toThrow(); + }); +});