-
-
Notifications
You must be signed in to change notification settings - Fork 576
Description
Describe the bug
form.Subscribe doesn't accept children as a prop attribute, only as JSX children, but the examples given showing that it accept children as props.
When using form.Subscribe with a selector prop, passing the render function via the children prop attribute doesn't work. The component only works when the render function is passed as JSX children (between opening and closing tags).
This creates an inconsistency with other form components like form.AppField, which accept children as a prop attribute.
Eventually both pattern works as expected but typescript complaining about the error.
Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-of4hmkxe?file=src%2FApp.tsx
Steps to reproduce
- Create a form using
withFormoruseForm - Use
form.Subscribewith aselectorprop - Pass the render function via the
childrenprop attribute
<form.Subscribe
children={(title) => {
return <div>{title}</div>
}}
selector={(state) => state.values.title}
/>Expected behavior
The form.Subscribe component should accept the render function via the children prop attribute, similar to how form.AppField works:
// This pattern should work (but currently doesn't)
<form.Subscribe
children={(title) => <div>{title}</div>}
selector={(state) => state.values.title}
/>
// This pattern works for form.AppField
<form.AppField
children={(field) => <input {...field} />}
name="title"
/>How often does this bug happen?
Every time
Screenshots or Videos
Selector error:
Props error:
Platform
- OS: Mac OS
- Version: Sequoia 15.5
TanStack Form adapter
react-form
TanStack Form version
^1.27.7
TypeScript version
^5.7.2
Additional context
No response