diff --git a/src/jsx/dom/index.ts b/src/jsx/dom/index.ts index 1949d2daf..6d147c1c5 100644 --- a/src/jsx/dom/index.ts +++ b/src/jsx/dom/index.ts @@ -3,9 +3,10 @@ * This module provides APIs for `hono/jsx/dom`. */ -import { isValidElement, memo, reactAPICompatVersion } from '../base' -import type { Child, DOMAttributes, JSX, JSXNode, Props } from '../base' +import { isValidElement, reactAPICompatVersion, shallowEqual } from '../base' +import type { Child, DOMAttributes, JSX, JSXNode, Props, FC, MemorableFC } from '../base' import { Children } from '../children' +import { DOM_MEMO } from '../constants' import { useContext } from '../context' import { createRef, @@ -72,6 +73,15 @@ const cloneElement = ( ) as T } +const memo = ( + component: FC, + propsAreEqual: (prevProps: Readonly, nextProps: Readonly) => boolean = shallowEqual +): FC => { + const wrapper = ((props: T) => component(props)) as MemorableFC + wrapper[DOM_MEMO] = propsAreEqual + return wrapper as FC +} + export { reactAPICompatVersion as version, createElement as jsx,