Skip to content

Commit

Permalink
feat(jsx): enable to use 'hono/jsx/dom' for replacement of 'react'.
Browse files Browse the repository at this point in the history
You can use dom-specific version of hooks and utils by importing from 'hono/jsx/dom'.
  • Loading branch information
usualoma committed Feb 2, 2024
1 parent 511b0ab commit 09da043
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/jsx/dom/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
export {
useState,
useEffect,
useRef,
useCallback,
use,
startTransition,
useTransition,
useDeferredValue,
startViewTransition,
useViewTransition,
useMemo,
useLayoutEffect,
} from '../hooks'
export { render } from './render'
export { Suspense, ErrorBoundary } from './components'
export { useContext } from '../context'
export type { Context } from '../context'
export { createContext } from './context'
export { memo, isValidElement } from '..'

import type { Props, Child, JSXNode } from '..'
import { jsx } from './jsx-runtime'
export const cloneElement = <T extends JSXNode | JSX.Element>(
element: T,
props: Props,
...children: Child[]
): T => {
return jsx(
(element as JSXNode).tag,
{
...(element as JSXNode).props,
...props,
children: children.length ? children : (element as JSXNode).children,
},
(element as JSXNode).key
) as T
}

0 comments on commit 09da043

Please sign in to comment.