-
-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jsx/dom): more react staff (#2132)
* fix(jsx): fix context provider with async component (#2124) * test(jsx): add test for Context with Suspense * fix(jsx): fix context provider with async component * chore: denoify * feat(jsx): Introduce useMemo and useLayoutEffect hooks * feat(jsx): Introduce isValidElement and cloneElement. * fix(jsx/dom): fix context handling in renderToDom * feat(jsx): enable to use 'hono/jsx/dom' for replacement of 'react'. You can use dom-specific version of hooks and utils by importing from 'hono/jsx/dom'. * refactor(jsx): refactor memo() * test(jsx/dom): migrate existing tests to use `requestAnimationFrame` * test(jsx): add tests * refactor(jsx): move constant to its own file * chore: denoify
- Loading branch information
Showing
28 changed files
with
860 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const DOM_RENDERER = Symbol('RENDERER') | ||
export const DOM_ERROR_HANDLER = Symbol('ERROR_HANDLER') | ||
export const DOM_STASH = Symbol('STASH') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/index.ts' | ||
export { render } from './render.ts' | ||
export { Suspense, ErrorBoundary } from './components.ts' | ||
export { useContext } from '../context.ts' | ||
export type { Context } from '../context.ts' | ||
export { createContext } from './context.ts' | ||
export { memo, isValidElement } from '../index.ts' | ||
|
||
import type { Props, Child, JSXNode } from '../index.ts' | ||
import { jsx } from './jsx-runtime.ts' | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.