TanStack / TanStack/form

useStore select value with type "File" doesnt update

Open
#1,539 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

v1 v2
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.