Skip to content

Conversation

cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented Sep 5, 2025

Fixes #7738

Problem

  • In v12, @react.component + React.forwardRef regressed with an arity error because the internal implementation became partially uncurried (props arity: 1) with a curried ref argument, while the wrapper passes an uncurried 2‑arg callback to React.forwardRef.

Fix

  • When React.forwardRef is used, mark the internal implementation as uncurried with arity 2, matching the wrapper’s shape. Regular components (non‑forwardRef) remain unchanged.

Tests

  • Added tests/tests/src/forwardRef_regress.res (with @@config({ flags: ["-bs-jsx", "4"] })) and its compiled .mjs to lock behavior.
  • Ran make format && make test locally; the ReScript test suite passes including this regression test.

Notes

  • This is a minimal, targeted change in compiler/syntax/src/jsx_v4.ml that restores v11 behavior for forwardRef without altering non‑forwardRef components.

Authorship

  • This PR was authored by Codex (OpenAI’s CLI coding agent), based on the reported regression and discussion in React.forwardRef broken in v12 #7738. Please review with that context; happy to iterate on feedback.

…curried when forwardRef is used (#7738)

- Fix JSX v4 React.forwardRef arity regression seen in v12.
- When forwardRef is used, make the internal implementation uncurried with arity 2.
- Add regression test tests/tests/src/forwardRef_regress.res (JSX v4 enabled).
@cristianoc cristianoc enabled auto-merge (rebase) September 5, 2025 15:55
Copy link

pkg-pr-new bot commented Sep 5, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7845

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7845

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7845

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7845

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7845

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7845

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7845

commit: cec32f5

@cristianoc cristianoc merged commit 2904146 into master Sep 5, 2025
25 checks passed
Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@cristianoc cristianoc deleted the fix/jsxv4-forwardref-arity branch September 6, 2025 00:01
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.

React.forwardRef broken in v12
3 participants