Skip to content

Commit 031a74e

Browse files
authored
fix: correct children rendering in TSX output (#53)
1 parent 9c32ec2 commit 031a74e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/renderers/__snapshots__/react.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { PropsWithChildren } from 'hono/jsx'
99
type Props = { attr?: 'a' | 'b', attrFooBar?: 'foo-bar', isFoo?: boolean, propFoo?: string, propBar?: string } & JSX.IntrinsicElements['div']
1010
1111
export function Foo({ children, attr, attrFooBar, isFoo, propFoo, propBar, ...props }: PropsWithChildren<Props>) {
12-
return (<div {...props} data-attr={attr} data-attr-foo-bar={attrFooBar} data-is-foo={isFoo} style={{ '--prop-foo': propFoo, '--prop-bar': propBar }} class="foo" >\${children}</div>)
12+
return (<div {...props} data-attr={attr} data-attr-foo-bar={attrFooBar} data-is-foo={isFoo} style={{ '--prop-foo': propFoo, '--prop-bar': propBar }} class="foo" >{children}</div>)
1313
}
1414
"
1515
`;
@@ -23,7 +23,7 @@ import type { JSX, PropsWithChildren } from 'react'
2323
type Props = { attr?: 'a' | 'b', attrFooBar?: 'foo-bar', isFoo?: boolean, propFoo?: string, propBar?: string } & JSX.IntrinsicElements['div']
2424
2525
export function Foo({ children, attr, attrFooBar, isFoo, propFoo, propBar, ...props }: PropsWithChildren<Props>) {
26-
return (<div {...props} data-attr={attr} data-attr-foo-bar={attrFooBar} data-is-foo={isFoo} style={{ '--prop-foo': propFoo, '--prop-bar': propBar }} className="foo" >\${children}</div>)
26+
return (<div {...props} data-attr={attr} data-attr-foo-bar={attrFooBar} data-is-foo={isFoo} style={{ '--prop-foo': propFoo, '--prop-bar': propBar }} className="foo" >{children}</div>)
2727
}
2828
"
2929
`;
@@ -37,7 +37,7 @@ import type { JSX, PropsWithChildren } from 'react'
3737
type Props = { } & JSX.IntrinsicElements['div']
3838
3939
export function Foo({ children, ...props }: PropsWithChildren<Props>) {
40-
return (<div {...props} className="foo" >\${children}</div>)
40+
return (<div {...props} className="foo" >{children}</div>)
4141
}
4242
"
4343
`;

src/renderers/react.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ function renderFunction(data: Data, isClass: boolean): string {
3232
].join(', ')
3333

3434
return `export function ${pascalCase(data.className)}({ ${args} }: ${hasChildren(data.tag) ? `PropsWithChildren<Props>` : `Props`}) {
35-
return (${renderTag(data, '${children}', isClass ? 'class' : 'className')})
35+
return (${renderTag(data, '{children}', isClass ? 'class' : 'className')})
3636
}`
3737
}
3838

39-
4039
export function render(name: string, data: Data, isHono = false): string {
4140
return `// Generated by MistCSS, do not modify
4241
import './${name}.mist.css'

0 commit comments

Comments
 (0)