Skip to content

Commit 634facf

Browse files
authored
fix(react-form): allow ReactNode to be returned from withForm / withFieldGroup (#1817)
1 parent 0c9c55a commit 634facf

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.changeset/cuddly-planets-dig.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/react-form': patch
3+
---
4+
5+
Allow returning all other `ReactNode`s not just `JSX.Element` in the `render` function of `withForm` and `withFieldGroup`.

packages/react-form/src/createFormHook.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import type {
1313
FormOptions,
1414
FormValidateOrFn,
1515
} from '@tanstack/form-core'
16-
import type { ComponentType, Context, JSX, PropsWithChildren } from 'react'
16+
import type {
17+
ComponentType,
18+
Context,
19+
PropsWithChildren,
20+
ReactNode,
21+
} from 'react'
1722
import type { FieldComponent } from './useField'
1823
import type { ReactFormExtendedApi } from './useForm'
1924
import type { AppFieldExtendedReactFieldGroupApi } from './useFieldGroup'
@@ -241,7 +246,7 @@ export interface WithFormProps<
241246
>
242247
}
243248
>,
244-
) => JSX.Element
249+
) => ReactNode
245250
}
246251

247252
export interface WithFieldGroupProps<
@@ -278,7 +283,7 @@ export interface WithFieldGroupProps<
278283
>
279284
}
280285
>,
281-
) => JSX.Element
286+
) => ReactNode
282287
}
283288

284289
export function createFormHook<
@@ -515,7 +520,7 @@ export function createFormHook<
515520
fields: TFields
516521
}
517522
>,
518-
) => JSX.Element {
523+
) => ReactNode {
519524
return function Render(innerProps) {
520525
const fieldGroupProps = useMemo(() => {
521526
return {

0 commit comments

Comments
 (0)