react / react/react

[Compiler Bug]: TanStack Form incompatibility

Open
#35,024 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: React Compiler Status: Unconfirmed Type: Bug
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

What kind of issue is this?
  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)
Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhASwLYAcIwC4AEwBUYCAYmggDYAmAwhAHZ4IAehAvgQGYwQYCAcgB0Aeh64MAWjjNWHEXjBshAHSYb2OfLyhM4eNMwIAVdnko1aAOQh4A6rgDWaJgHMAFMWoBDAEY0ADQEABZotLQITAScyEQEfoHU8WB4MG7uIeGR0fH+EBDUCL4xnACURBoEBHJMabxUdAQAvCRkVnSMLBYAPGkZHgB8nuXVBDAIeLAxnuM1vUk0Q-M1BP1YpUPAS9ScvWJgm0wrmnhq53jAAIQ5UTEAZA8aF6+XF71uWFDnZ2--eAAbr5qFAEC1gDwmrQRGlfKwRMDQQhOC93uiLsx6KFSu5wcBPAhKi0ho1rCIcUxaMVsbiEISlL4YHi8IiQWDyqi-hi8GJTgCuWt1mJdqcamMmFytGwdIQePpDMYYuYOJ1aE4YK4PN5EgEaLF4j49SkCANMrFKsA0XUGlDrK12hRod0FIReqb0ubSaM0ZNpjBZmiPqKg5cNlsdsb9odjvz0Z8mN9fgC3kiwRC7XRYXh4Qg2cipTzMUxaR58YTiaTMzDKdSEKW8Qyc8ypvmOYWAXzQwcQ2cJZwQEEQHUoe4UOhsLhCHgAJ5YBAJAAKoPcbgA8lgjMwwLFePxBEJ-MbpFgV25pJNfIZZAIsGhijAxLQ0GkhABuF5MbzjMRiOTYe94SVABZCAoniNQQBBahII0bgwCAsA7R3ZcoFXJgNy3epyjfQdwFCCAAHcAEkegDEEwBQHgKJRIA

Repro steps

When rendering something with an expression conditionally like this {!hidden && <input value={field.state.value} onChange={(e) => field.handleChange(e.target.value)}/>}, the "memo dependencies" to trigger a rerender are hidden and field.
This is different when rendering the input without a condition like this {<input value={field.state.value} onChange={(e) => field.handleChange(e.target.value)}/>}, the "memo dependencies" are "field.handleChange" and "field.state.value".

This change of behavior can cause some unexpected issues:

  • in my case, using @tanstack/form, the field property isn't reactive in itself but its subproperties are. This prevents the input from updated its value when the user types inside the input
  • if field was reactive, a change inside field that is neither the value or handleChange would trigger a rerender that shouldn't be needed

This can happen with a bool && <div> or with a bool ? <div> : <div> expression

Not really sure if this is expected behavior and if it is, what is the recommended fix.
I've opened an issue over at @tanstack/form

How often does this bug happen?

Every time

What version of React are you using?

19.0.0

What version of React Compiler are you using?

1.0.0

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 with the linked React Playground reproduction and compare the generated memo dependencies for conditional and unconditional input rendering. Read the TanStack Form issue for the affected reactive-field context, then determine the intended compiler behavior and verify the result against the reported typing scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
compilers, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.