Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- JSX preserve mode: fix "make is not a valid component name". https://github.com/rescript-lang/rescript/pull/7831
- Rewatch: include parser arguments of experimental features. https://github.com/rescript-lang/rescript/pull/7836
- Stop mangling tagged templates and backquoted strings. https://github.com/rescript-lang/rescript/pull/7841
- JSX v4: fix arity mismatch for `@react.component` with `React.forwardRef`. https://github.com/rescript-lang/rescript/pull/7845

#### :memo: Documentation

Expand Down
5 changes: 5 additions & 0 deletions compiler/syntax/src/jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
| _ -> Pat.record (List.rev patterns_with_label) Open
in
let expression =
(* Shape internal implementation to match wrapper: uncurried when using forwardRef. *)
Exp.fun_ ~arity:(Some 1) ~async:is_async Nolabel None
(Pat.constraint_ record_pattern
(Typ.constr ~loc:empty_loc
Expand All @@ -748,6 +749,10 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
| _ -> [Typ.any ()]))))
expression
in
let expression =
if has_forward_ref then expression |> Ast_uncurried.uncurried_fun ~arity:2
else expression
in
let expression =
(* Add new tupes (type a,b,c) to make's definition *)
newtypes
Expand Down
10 changes: 10 additions & 0 deletions tests/tests/src/forwardRef_regress.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

import * as React from "react";

let make = React.forwardRef((props, ref) => props.children);

export {
make,
}
/* make Not a pure module */
8 changes: 8 additions & 0 deletions tests/tests/src/forwardRef_regress.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@@config({flags: ["-bs-jsx", "4"]})

@react.component
let make = React.forwardRef((~className=?, ~children, _ref) => {
// Constrain type variables to avoid value restriction
let _: option<string> = className
children
})
Loading