diff --git a/packages/react/runtime/src/lifecycle/isRendering.ts b/packages/react/runtime/src/lifecycle/isRendering.ts index 54289c6555..4ca86b4b32 100644 --- a/packages/react/runtime/src/lifecycle/isRendering.ts +++ b/packages/react/runtime/src/lifecycle/isRendering.ts @@ -17,14 +17,11 @@ const setIsRendering = () => { }); }; -hook(options, RENDER_COMPONENT, (old, ...args) => { +const onRenderHook = (old: ((...args: T) => void) | undefined, ...args: T) => { /* v8 ignore next */ - old?.(...args); + if (old) old(...args); setIsRendering(); -}); +}; -hook(options, ROOT, (old, ...args) => { - /* v8 ignore next */ - old?.(...args); - setIsRendering(); -}); +hook(options, RENDER_COMPONENT, onRenderHook); +hook(options, ROOT, onRenderHook); diff --git a/packages/react/runtime/src/lynx/performance.ts b/packages/react/runtime/src/lynx/performance.ts index 3d3afa6cfb..0c12e259c1 100644 --- a/packages/react/runtime/src/lynx/performance.ts +++ b/packages/react/runtime/src/lynx/performance.ts @@ -2,7 +2,6 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. import { options } from 'preact'; -import type { VNode } from 'preact'; import { __globalSnapshotPatch } from '../lifecycle/patch/snapshotPatch.js'; import { RENDER_COMPONENT, ROOT } from '../renderToOpcodes/constants.js'; @@ -130,23 +129,15 @@ function initTimingAPI(): void { } }; - hook(options, RENDER_COMPONENT, (old, vnode: VNode, c) => { + const onHook = (old: ((...args: T) => void) | undefined, ...args: T) => { helper(); /* v8 ignore start */ - if (old) { - old(vnode, c); - } + if (old) old(...args); /* v8 ignore stop */ - }); + }; - hook(options, ROOT, (old, vnode: VNode, parentDom) => { - helper(); - /* v8 ignore start */ - if (old) { - old(vnode, parentDom); - } - /* v8 ignore stop */ - }); + hook(options, RENDER_COMPONENT, onHook); + hook(options, ROOT, onHook); } /**