form
form copied to clipboard
form.Field options does not inherit from form options
Describe the bug
DefaultValue from form instatiation is not inherited by form.field
options inside render function
Your minimal, reproducible example
Se code below
Steps to reproduce
const form = useForm({
defaultValues: {
name: 'Hello',
}
})
return (
<form.Field name="name" children={({ options }) => {
console.log(options.defaultValue)
return <View />
}} />
)
Will log undefined
Expected behavior
This value is only set when setting the defaultValue on the form.Field directly.
The defaultValue is retrievable via form.options.defaultValues?.name
but I think the value should be Hello
when accessing the options object in the render function on the form.Field
Or maybe the best solution would be that the value is
- defaultValue defined on the form.Field,
- If unassigned in 1, it inherits from the form instantiation
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
React Native
TanStack Form adapter
react-form
TanStack Form version
0.33.0
TypeScript version
No response
Additional context
No response