Describe the bug
Given...
const form = useForm({
todos: [
{text: 'Buy X'}
]
});
...as far as I know, this
<form.Field
name="todos"
mode="array"
children={(arrayFieldApi) => {
const items = arrayFieldApi.state.value;
return (
//jsx
)
}}
/>
should re-render the children only when the size f the array changes (after add/remove item), and should not re-render if the changes is on todos[0].text (items count is still 1).
This can be seen an equivalent to
<form.Subscribe
selector={state => state.values["todos"].length}
children={(_) => {
/// ...
}}
/>
Problem
I noticed that the children is called twice for the same items count, but only on first render.
For example:
- the form load
children is invoked (render)
- you update
todos[0].text
children is invoked again
- you update
todos[0].text again
children is NOT invoked again (true for follow up changes as well)
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-form-hapw5etq?file=src%2Findex.tsx
Steps to reproduce
Expected behavior
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
TanStack Form adapter
react-form
TanStack Form version
1.23.7
TypeScript version
No response
Additional context
No response