Skip to content

Comments

🔬 V8 (#12309)#12333

Open
bluebill1049 wants to merge 65 commits intomasterfrom
react-complier
Open

🔬 V8 (#12309)#12333
bluebill1049 wants to merge 65 commits intomasterfrom
react-complier

Conversation

@bluebill1049
Copy link
Member

@bluebill1049 bluebill1049 commented Oct 12, 2024

v8

  • Support react-compiler
  • Support flat field array
  • ⚠️ Breaking change: pass input ref instead of partial (Passing whole element to ref in Controller #12773)
  • ⚠️ Breaking change: rename useFieldArray
    • id to key
    • keyName props removed for useFieldArray
const { fields, append } =useFieldArray()

// data will be part of the submission 
append({
  key: 'key',  // does not affect render key
  id: 'key',  // does not affect render key
})

field[0].key // will still be uniq id for re-render

Important: use replace from useFieldArray instead, update entire field array with setValue will be removed in the next major version.

install

related #12990

* test: Add task running unit tests with react-compiler

* Use official compiler runtime

* 📖 fix: code example input field placeholder name (#12296)

* 🐞 fix: #12294 ensure Invalid Date is evaluated correctly (#12295)

* fix: ensure Invalid Date is evaluated correctly

* fix: #12294 ensure Invalid Date is evaluated correctly

* fix: #12294 ensure Invalid Date is evaluated correctly

* Update createFormControl.ts

* Update createFormControl.ts

* Update createFormControl.ts

---------

Co-authored-by: Beier (Bill) <[email protected]>

---------

Co-authored-by: Kim Sang Du <[email protected]>
Co-authored-by: Toshiki Saito <[email protected]>
Co-authored-by: Beier (Bill) <[email protected]>
@bluebill1049 bluebill1049 marked this pull request as draft October 12, 2024 22:18
@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2024

Size Change: -138 B (-0.24%)

Total Size: 58.6 kB

Filename Size Change
dist/index.cjs.js 11.5 kB -26 B (-0.23%)
dist/index.esm.mjs 22.2 kB -40 B (-0.18%)
dist/index.umd.js 11.5 kB -21 B (-0.18%)
dist/react-server.esm.mjs 13.3 kB -51 B (-0.38%)

compressed-size-action

@bluebill1049 bluebill1049 changed the title test: Add task running unit tests with react-compiler (#12309) feat: exp with react-compiler (#12309) Oct 19, 2024
@ellemedit
Copy link

could I know what's blocking this?

@bluebill1049
Copy link
Member Author

could I know what's blocking this?

I will need more time to get to it and then release an RC version of it later.

@stale

This comment was marked as outdated.

@stale stale bot added the stale label May 6, 2025
@bluebill1049 bluebill1049 removed the stale label May 6, 2025
@ybelakov

This comment was marked as spam.

@bluebill1049 bluebill1049 changed the title feat: exp with react-compiler (#12309) 🔬 feat: exp with react-compiler (#12309) Jun 9, 2025
@eugene-mohc
Copy link

I have found an issue in the latest beta version where formState from useFormContext and useFormState inside of a nested component is memoized incorrectly by the compiler and doesn't trigger re-renders.

Minimal example to show the issue: https://codesandbox.io/p/devbox/q3kgmx?file=%2Fapp%2Fpage.tsx

Press the submit button. The form shouldn't submit because of an error, but the Component doesn't reflect that there's an error.

@bluebill1049
Copy link
Member Author

I have found an issue in the latest beta version where formState from useFormContext and useFormState inside of a nested component is memoized incorrectly by the compiler and doesn't trigger re-renders.

Minimal example to show the issue: https://codesandbox.io/p/devbox/q3kgmx?file=%2Fapp%2Fpage.tsx

Press the submit button. The form shouldn't submit because of an error, but the Component doesn't reflect that there's an error.

<FormProvider {...form} formState={formState}> we will have to do this unfortunately.

@bluebill1049 bluebill1049 marked this pull request as ready for review December 11, 2025 09:35
@ivan-palatov
Copy link

id has made most of the complain over the years, key is a reserved keywords for react props make more sense to migrate over.

key is reseved in react, yes, but it isn't reserved in js or on the server. I think that just doing {key: string; value: T} instead of T & {key: string} is a more elegant and robust solution overall.

Also, I wonder if its the only reason why in the current implementation you coundn't use useFieldArray on an array of primitives? If so, it would be cool to get this functionality. We have multiple places in our apps, where we have to first make array of objects out of array of primitives to pass it to default values and than do the reverse on validation step. It is one of the pain points of using this library for us.

It would be cool to see this fixed in v8

@ivan-palatov
Copy link

as for watch(), we have a relatively large project which uses rhf heavily and we've been able to migrate all our code to use useWatch in components bodies and getValues in callbacks and effects. Maybe its just our experience, but I cant imagine a case where it would be beneficial to use watch(). And I wounder if those potential cases could be easily and more idiomatically accurately be solved with formData.subscribe()?

@lukasvice
Copy link

id has made most of the complain over the years, key is a reserved keywords for react props make more sense to migrate over.

key is reseved in react, yes, but it isn't reserved in js or on the server. I think that just doing {key: string; value: T} instead of T & {key: string} is a more elegant and robust solution overall.

Also, I wonder if its the only reason why in the current implementation you coundn't use useFieldArray on an array of primitives? If so, it would be cool to get this functionality. We have multiple places in our apps, where we have to first make array of objects out of array of primitives to pass it to default values and than do the reverse on validation step. It is one of the pain points of using this library for us.

It would be cool to see this fixed in v8

I fully agree. I also think it’s more intuitive to return the defined value rather than a modified object with an added key. This way, the value reference can be preserved as well (though that would also be possible when adding the key property).

bluebill1049 and others added 11 commits December 31, 2025 10:39
Update ArrayPath type to allow arrays of primitive values (string[],
number[], etc.) in addition to object arrays.

Previously, useFieldArray field types were limited to objects.
Now primitive types are supported by removing the BrowserNativeObject
check from ArrayPathImpl, enabling use cases like:
- tags: string[]
- scores: number[]
- matrix: string[][]

This is a type-only change with no runtime modifications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.