useStore select value with type "File" doesnt update
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 682
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 7
Description
Describe the bug
using useStore with selector that returns a File instance never been updated. I assume it is because the shallow function used internally by useStore doesnt work as expected when comparing File instance.
Your minimal, reproducible example
Here in the markdown
Steps to reproduce
trying the shallow function
import { shallow } from 'tanstack/react-form';
const a = new File(["a"], "a");
const b = new File(["b"], "b");
console.log(shallow(a, b)); // always return true;
real use case
const field = useFieldContext<File | null>()
const value = useStore(field.store, (state) => state.value);
console.log('file name', value?.name) // once we have the value, the value is never changed again.
<input type="file" onChange={e => field.handleChange(e.target.files?.[0] ?? null)} />
Expected behavior
I expect the subscribed value should be updated whenever we update the File
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
- macOS
- Chrome
TanStack Form adapter
react-form
TanStack Form version
1.9.0
TypeScript version
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the shallow function and the useStore selector path described in the report, then reproduce the comparison with the provided File values in the React form adapter. Done means distinct File selections cause the subscribed value to update, with regression coverage for the reported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100