Skip to content

Commit

Permalink
feat: import jsx function from hono/jsx/dom/jsx-runtime (#35)
Browse files Browse the repository at this point in the history
* feat: import jsx function from hono/jsx/dom/jsx-runtime

* refactor: Remove children from the type of `createElement()` since it is not used.

* chore: bump `hono` to `4.0.0`

* test: update expected result for [email protected]
  • Loading branch information
usualoma authored Feb 9, 2024
1 parent 83ef397 commit a186c42
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ createClient({
const { hydrateRoot } = await import('react-dom/client')
hydrateRoot(root, elem)
},
createElement: async (type: any, props: any, ...children: any[]) => {
createElement: async (type: any, props: any) => {
const { createElement } = await import('react')
return createElement(type, props, ...children)
return createElement(type, props)
},
})
```
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"@types/node": "^20.10.5",
"eslint": "^8.56.0",
"glob": "^10.3.10",
"hono": "4.0.0-rc.4",
"hono": "^4.0.0",
"np": "7.7.0",
"prettier": "^3.1.1",
"publint": "^0.2.7",
Expand Down
2 changes: 1 addition & 1 deletion src/client/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jsx as jsxFn } from 'hono/jsx'
import { render } from 'hono/jsx/dom'
import { jsx as jsxFn } from 'hono/jsx/dom/jsx-runtime'
import { COMPONENT_NAME, DATA_SERIALIZED_PROPS } from '../constants.js'
import type { CreateElement, Hydrate } from '../types.js'

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

/** JSX */
export type CreateElement = (type: any, props: any, ...children: any[]) => Node | Promise<Node>
export type CreateElement = (type: any, props: any) => Node | Promise<Node>
export type Hydrate = (children: Node, parent: Element) => void | Promise<void>
2 changes: 1 addition & 1 deletion test/hono-jsx/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('With preserved', () => {
expect(res.status).toBe(200)
// hono/jsx escape a single quote to &#39;
expect(await res.text()).toBe(
'<!DOCTYPE html><html><head><title></title><script type="module" src="/app/client.ts"></script></head><body><honox-island component-name="Counter.tsx" data-serialized-props="{&quot;initial&quot;:5}"><div><p>Count: 5</p><button onClick="() =&gt; setCount(count + 1)">Increment</button></div></honox-island></body></html>'
'<!DOCTYPE html><html><head><title></title><script type="module" src="/app/client.ts"></script></head><body><honox-island component-name="Counter.tsx" data-serialized-props="{&quot;initial&quot;:5}"><div><p>Count: 5</p><button>Increment</button></div></honox-island></body></html>'
)
})

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# bun ./bun.lockb --hash: 9C49BBA32CA67679-baa7eeb717c50742-8D13D55E67871FAC-20ed8b88d9808e43
# bun ./bun.lockb --hash: EDF7F17611AB5672-40bb59ecd35567d5-886AD0DEC253E9B8-04fc8ad6efeb3e35


"@aashutoshrathi/word-wrap@^1.2.3":
Expand Down Expand Up @@ -2598,10 +2598,10 @@ hono@*:
resolved "https://registry.npmjs.org/hono/-/hono-4.0.0-rc.2.tgz"
integrity sha512-c7PeKKtwidjkgurjyjKQpCr+oRuL9TXP1JzxqKxof2f4UT/CjEXKQkreawTzMjpalujrSCYcTOm3SBkkW0NxpQ==

"[email protected]-rc.4":
version "4.0.0-rc.4"
resolved "https://registry.npmjs.org/hono/-/hono-4.0.0-rc.4.tgz"
integrity sha512-v66lcctPzahRBhzyJKFNgwdq6smjRpgQWwHzLY4lEZDBHPr/lKRMvOOrDkBNyy2y1gYKA175BE4X8VU/0wImTw==
hono@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/hono/-/hono-4.0.0.tgz"
integrity sha512-8dKhuBBpRZEodUttQhrSFJ6PQqHRjXHyeeegfxOf132pvgbf0tOb9qqb7q7eYwAWpOcYrsUOsWdJ0sQIIovhZg==

hosted-git-info@^2.1.4:
version "2.8.9"
Expand Down

0 comments on commit a186c42

Please sign in to comment.