TanStack / form

🤖 Powerful and type-safe form state management for the web. TS/JS, React Form, Solid Form, Lit Form and Vue Form.
https://tanstack.com/form
MIT License
3.83k stars 348 forks source link

Support for React Compiler #1030

Closed Axenu closed 9 hours ago

Axenu commented 1 week ago

Describe the bug

While using this package in our react project, we needed to access the current value of one of the fields in the form, to use that to update the possible values in another field (select).

The problem is that we have the eslint-plugin-react-compiler plugin, which does not accept the form.useStore hook with the exception "Hooks must be the same function on every render, but this value may change over time to a different function.".

The UI works as expected, but it seems like the way of accessing the current value in a reactive manor is not correct according to the rules for hooks.

I added a fork of this repo, where I have added the eslint plugin. The eslint check of the useForm file fails.

Your minimal, reproducible example

https://github.com/Axenu/tanstack-form/tree/react-compiler

Steps to reproduce

  1. run ppm install
  2. npm run test:eslint

Expected behavior

There should not be any lint errors when using form.useStore

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

MacOS, eslint

TanStack Form adapter

None

TanStack Form version

0.36.2

TypeScript version

No response

Additional context

No response

crutchcorn commented 4 days ago

Issues with React Compiler are being addressed in this PR:

1035

crutchcorn commented 9 hours ago

0.39.0 should fix the issues with React Compiler. Please open a new issue if you run into further issues with it

Axenu commented 8 hours ago

Wonderful work! Thank you!