@@ -17,8 +17,8 @@ import type {
1717import type {
1818 ComponentType ,
1919 Context ,
20+ FunctionComponent ,
2021 PropsWithChildren ,
21- ReactNode ,
2222} from 'react'
2323import type { FieldComponent } from './useField'
2424import type { ReactFormExtendedApi } from './useForm'
@@ -191,7 +191,10 @@ export type AppFieldExtendedReactFormApi<
191191 TSubmitMeta ,
192192 NoInfer < TFieldComponents >
193193 >
194- AppForm : ComponentType < PropsWithChildren >
194+ AppForm : ComponentType <
195+ // PropsWithChildren<P> is not optional in React 17
196+ PropsWithChildren < { } >
197+ >
195198 }
196199
197200export interface WithFormProps <
@@ -226,8 +229,8 @@ export interface WithFormProps<
226229 > {
227230 // Optional, but adds props to the `render` function outside of `form`
228231 props ?: TRenderProps
229- render : (
230- props : PropsWithChildren <
232+ render : FunctionComponent <
233+ PropsWithChildren <
231234 NoInfer < TRenderProps > & {
232235 form : AppFieldExtendedReactFormApi <
233236 TFormData ,
@@ -246,8 +249,8 @@ export interface WithFormProps<
246249 TFormComponents
247250 >
248251 }
249- > ,
250- ) => ReactNode
252+ >
253+ >
251254}
252255
253256export interface WithFieldGroupProps <
@@ -259,8 +262,8 @@ export interface WithFieldGroupProps<
259262> extends BaseFormOptions < TFieldGroupData , TSubmitMeta > {
260263 // Optional, but adds props to the `render` function outside of `form`
261264 props ?: TRenderProps
262- render : (
263- props : PropsWithChildren <
265+ render : FunctionComponent <
266+ PropsWithChildren <
264267 NoInfer < TRenderProps > & {
265268 group : AppFieldExtendedReactFieldGroupApi <
266269 unknown ,
@@ -283,8 +286,8 @@ export interface WithFieldGroupProps<
283286 TFormComponents
284287 >
285288 }
286- > ,
287- ) => ReactNode
289+ >
290+ >
288291}
289292
290293export function createFormHook <
@@ -342,13 +345,13 @@ export function createFormHook<
342345 > {
343346 const form = useForm ( props )
344347
345- const AppForm = useMemo ( ( ) => {
346- const AppForm = ( ( { children } ) => {
348+ // PropsWithChildren<P> is not optional in React 17
349+ const AppForm = useMemo < ComponentType < PropsWithChildren < { } > > > ( ( ) => {
350+ return ( { children } ) => {
347351 return (
348352 < formContext . Provider value = { form } > { children } </ formContext . Provider >
349353 )
350- } ) as ComponentType < PropsWithChildren >
351- return AppForm
354+ }
352355 } , [ form ] )
353356
354357 const AppField = useMemo ( ( ) => {
@@ -521,7 +524,7 @@ export function createFormHook<
521524 fields : TFields
522525 }
523526 > ,
524- ) => ReactNode {
527+ ) => ReturnType < FunctionComponent > {
525528 return function Render ( innerProps ) {
526529 const fieldGroupProps = useMemo ( ( ) => {
527530 return {
0 commit comments