Skip to content

Commit c4c3935

Browse files
committed
-fix automate jsx mode children cannot render bug. when use jsx automate mode,jsx will group children in props
- pkg lack jsx-dev-runtime declaration
1 parent d7bd8d7 commit c4c3935

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
"import": "./jsx-runtime.js",
1717
"require": "./jsx-runtime.js",
1818
"types": "./jsx-runtime.d.ts"
19+
},
20+
"./jsx-dev-runtime": {
21+
"import": "./jsx-dev-runtime.js",
22+
"require": "./jsx-dev-runtime.js",
23+
"types": "./jsx-dev-runtime.d.ts"
1924
}
2025
},
2126
"typings": "./dist/types/index.d.ts",

src/h.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ import { FC, FreNode, FreText, Fiber } from './type'
44
// for jsx2
55
export const h = (type: string | FC, props: any, ...kids: FreNode[]) => {
66
props = props || {}
7-
kids = flat(arrayfy(props.children || kids))
87

9-
if (kids.length) props.children = kids.length === 1 ? kids[0] : kids
8+
// JSX Transform 会将 children 作为 props 传递
9+
if (props.children !== undefined) {
10+
kids = flat(arrayfy([props.children]))
11+
} else if (kids.length) {
12+
kids = flat(arrayfy(kids))
13+
}
14+
15+
if (kids.length) {
16+
props.children = kids.length === 1 ? kids[0] : kids
17+
}
1018

1119
const key = props.key || null
1220
const ref = props.ref || null

0 commit comments

Comments
 (0)